Kaydet (Commit) 2bde26b2 authored tarafından SiegeLord's avatar SiegeLord

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.
üst 52a179dc
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment