RomanYankovsky / DelphiAST

Abstract syntax tree builder for Delphi
Mozilla Public License 2.0
271 stars 116 forks source link

Cannot parse System.SysUtils in 10.4.2 - should there be a default set of defines? #308

Closed darnocian closed 3 years ago

darnocian commented 3 years ago

Looks like issue is with {$IFDEF...}

I started adding defines to the lexer and the error has moved along, so will be looking at identifying the next issue.

So I was wondering if there should not be a default set of defines in the examples so we can see some of the built in delphi units passing.

I'll post back or submit something when I discover more.

darnocian commented 3 years ago

Found the following scenario doesn't parse:

type TRecord = record Event: integer; end align {$IFDEF DEBUG} 16 {$ENDIF};

Above is just a mini version of what I found in SysUtils that resulted in the failure.

I'll check the code next.

RomanYankovsky commented 3 years ago

So I was wondering if there should not be a default set of defines in the examples so we can see some of the built in delphi units passing.

Try TDelphiAST.InitDefinesDefinedByCompiler()

RomanYankovsky commented 3 years ago

end align {$IFDEF DEBUG} 16 {$ENDIF};

Interesting case. align keyword there is not supported by parser. I'll fix that.

darnocian commented 3 years ago

Yeah, was interesting. I have not used that feature yet either.

Thanks for highlighting InitDefinesDefinedByCompiler(). I must have been blind.

I started trying to introduce align, but am glad to observe the change for next time ;)

darnocian commented 3 years ago

Hi Roman. I was experimenting with adding the align keyword. I managed to get the parser to work, but wasn't sure how to get the packed size into the xml node structure as an attribute. I'm happy to submit a pull request for review.

RomanYankovsky commented 3 years ago

Of course, please submit a PR

darnocian commented 3 years ago

I think I sorted it out. PR #311