grammars-v4
grammars-v4 copied to clipboard
[C Language] Error Parsing of Structure Declarations
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.