RomanYankovsky / DelphiAST

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

Need list of all comments #292

Closed PeterPanino closed 4 years ago

PeterPanino commented 4 years ago

I need a list of all the comments in the unit. Unfortunately, comments currently are not parsed.

RomanYankovsky commented 4 years ago

Actually, comments are parsed. Check TPasSyntaxTreeBuilder.Comments right after parsing. There is a list of all comments in unit.

PeterPanino commented 4 years ago

How can I extract the comment STRINGS from TPasSyntaxTreeBuilder.Comments?

In ParserDemo, Compiler error says: E2233 Property 'Comments' inaccessible here

RomanYankovsky commented 4 years ago

I have updated ParserDemo, take a look.

PeterPanino commented 4 years ago

Roman, thank you very much!

What would you suggest as the FASTEST parser for the XML? For example, to get a list of all strings in the unit?

PeterPanino commented 4 years ago

I have added a Strings property to TPasSyntaxTreeBuilder. In this way, I can get all the strings in the unit easily inside a single string. What do you think about the implementation? Is it correct? DelphiAST.zip

PeterPanino commented 4 years ago

I have now also added a Numbers property to TPasSyntaxTreeBuilder. In this way, I can get all the numbers in the unit easily inside a single string. What do you think about the implementation? Is it correct? DelphiAST 11.12.2019 16.08.zip

RomanYankovsky commented 4 years ago

Looks correct.

I'm just curious, why do you need all strings and numbers?

PeterPanino commented 4 years ago

I plan to create a semantic database of Delphi source files.

PeterPanino commented 4 years ago

See also the issue of missing end-position information in comment nodes. (issue #294)

RomanYankovsky commented 4 years ago

Ok, this one is resolved.