From 2bde26b2027d683619a8c6013db8d63a92291a75 Mon Sep 17 00:00:00 2001 From: SiegeLord Date: Sun, 23 Mar 2014 12:44:17 -0400 Subject: [PATCH] Rust: Fix parsing of attributes in structs/enums. Previously, things like: struct Foo { #[bar] baz: int } or struct Foo { #![bar] baz: int } would horribly confuse the parser and prevent proper parsing of the rest of the file. --- tagmanager/ctags/rust.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tagmanager/ctags/rust.c b/tagmanager/ctags/rust.c index 5512a2be..968e8001 100644 --- a/tagmanager/ctags/rust.c +++ b/tagmanager/ctags/rust.c @@ -715,9 +715,29 @@ static void parseStructOrEnum (lexerState *lexer, vString *scope, int parent_kin vString *field_name = vStringNew(); while (lexer->cur_token != TOKEN_EOF) { + int goal_tokens2[] = {'}', ','}; + /* Skip attributes. Format: + * #[..] or #![..] + * */ + if (lexer->cur_token == '#') + { + advanceToken(lexer, TRUE); + if (lexer->cur_token == '!') + advanceToken(lexer, TRUE); + if (lexer->cur_token == '[') + { + /* It's an attribute, skip it. */ + skipUntil(lexer, NULL, 0); + } + else + { + /* Something's up with this field, skip to the next one */ + skipUntil(lexer, goal_tokens2, 2); + continue; + } + } if (lexer->cur_token == TOKEN_IDENT) { - int goal_tokens2[] = {'}', ','}; if (strcmp(lexer->token_str->buffer, "priv") == 0) { advanceToken(lexer, TRUE);