dissect.cstruct icon indicating copy to clipboard operation
dissect.cstruct copied to clipboard

Incorrect parsing of multiple declarators in a single declaration

Open d3dave opened this issue 1 year ago • 1 comments

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.

d3dave avatar Apr 29 '24 15:04 d3dave

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.

Schamper avatar May 06 '24 09:05 Schamper