grammars-v4 icon indicating copy to clipboard operation
grammars-v4 copied to clipboard

[C Language] Error Parsing of Structure Declarations

Open xurongchen opened this issue 3 years ago • 0 comments
trafficstars

I have made a pull request to fix the problem. Pull Request 2608

Problem Example:

struct A { int x;};

In c.g4, int x; above is a structDeclaration, which has the following definition:

structDeclaration
    :   specifierQualifierList structDeclaratorList? ';'
    |   staticAssertDeclaration
    ;

A correct analysis should treat the identifier x as a part of structDeclaratorList. However, with the definition for structDeclaratorList above. I found that x was incorrectly parsed into specifierQualifierList. It is because specifierQualifierList may contain typedefName, which finally can accept an identifier.

xurongchen avatar May 05 '22 07:05 xurongchen