DelphiAST icon indicating copy to clipboard operation
DelphiAST copied to clipboard

Added support for {..} and (*..*) comments and attaching them nodes

Open neslib opened this issue 9 years ago • 2 comments

Currently, DelphiAST only extracts "//..." style comments. This branch adds support for "{..}" and "(..)" comments as well. This only required changes to SimpleParser.Lexer.pas.

In addition, I added support for attaching the last preceding comments to TSyntaxNodes, through the new TSyntaxNode.LastPrecedingCommentNode property.

Support for this is disabled by default, since not everyone may be interested in comments. To attach the comments to their nodes, I added TPasSyntaxTreeBuilder.AttachCommentNodes.

There have been discussions about where to place comment nodes in the tree. The approach I took here was not the place comments nodes in the tree, but to associate each comment with the node that succeeds it. This is the same convention that is used in the Delphi RTL/VCL/FMX source code: the documentation for a declaration is written in a comment preceding the declaration itself.

If there are more comments preceding a node, then only the last comment is attached.

neslib avatar Aug 25 '16 17:08 neslib

Related to #39

EMBBlaster avatar Oct 26 '17 18:10 EMBBlaster

Support for multiline comments has been implemented in 25eb2ac8 - so this can be closed imo

sglienke avatar Aug 05 '22 13:08 sglienke