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.
This commit is contained in:
parent
52a179dce1
commit
2bde26b202
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user