dissect.cstruct
dissect.cstruct copied to clipboard
Incorrect parsing of multiple declarators in a single declaration
The definition struct X { int x : 16, y : 16; } gets parsed incorrectly into the following tokens:
[<Token.STRUCT value='struct'>,
<Token.IDENTIFIER value='X'>,
<Token.BLOCK value='{'>,
<Token.IDENTIFIER value='int'>,
<Token.IDENTIFIER value='x'>,
<Token.NAME value='y : 16'>,
<Token.EOL value=';'>,
<Token.BLOCK value='}'>]
As you can see, x : 16 is mistakenly truncated and treated as an identifier instead of a name like y : 16.
This is unfortunately a known limitation of the current parser. Would love to support this since I also regularly run into this issue. Not sure how feasible it is with the current parser though. Ideally we get a better parser with perhaps a proper AST down the line.