[antlr-interest] AST specification and processing

Alexey Demakov demakov at ispras.ru
Wed Oct 13 09:15:34 PDT 2004



Hi all,

The next task after parsing input text is AST construction. After construction AST can be transformed, processed etc.
ANTLR can be used for parsing and for tree construction. But what if tool (translator, preprocessor, interpreter...)
is developed by more than one prorgamer? How to split translator into subsystems, how to specify interfaces between them?
Natural decomposition of translator is around internal representation of input data, i.e. around AST:
Parser checks syntax and builds AST, semantics checker verifies static semantics and adds additional information to AST.
After that AST can be transformed, processed in other way, output code can be generated.
All of these subsystems depends on AST format only, they are (theoretically) independent of each other.
If there is separate AST specification (not in ANTLR parser), all of these subsystems (including parser)
can be developed independently and at the same time. AST specification can be used as a contract between
developers of different subsystems. According to my experience, it speeds up development and reduces number of errors.

I propose the notation called TreeDL to describe tree-like structures, open-source tool that checks consistence of tree description
and translates tree description to a set of classes (now in Java, C# will be added in near future). The TreeDL tool also
can generate HTML cross-referenced version of tree description to be used as documentation.
Tree nodes can be decorated by dynamic attributes to store additional information.
There is powerful template engine to generate code from tree.
Also there is framework for rapid tool development - library for error reporting, functionality extention by plugins -
TreeDL tool itself uses tree description in TreeDL, mentioned template engine and framework, so source code 
can be used as an example.

Additional docs and downloads are at http://treedl.sourceforge.net
Example tree description http://treedl.sourceforge.net/treedl/treedl/com/unitesk/atp/treedl/TreeDL.tdl-xref/index.html
TreeDL BNF grammar http://treedl.sourceforge.net/treedl/bnf/TreeDL.bnf/index.html
TreeDL language description http://treedl.sourceforge.net/treedl/treedl_en.html
TreeDL tool description http://treedl.sourceforge.net/treedl/treedl_tool_end.html
Template engine usage example http://treedl.sourceforge.net/treedl/xref/com/unitesk/atp/treedl/JavaNodeGenerator.html

Please feel free to ask additional questions, any feedback is highly appreciated.

I use ANTLR since it was PCCTS :) it is great tool and I wish to share my experience with ANTLR community.
Proposed technology was approbated in our projects on development of extentions of full-size programming languages
(C, Java and C# for now) for specification and testing purposes.

Best regards,
Alexey
-----
Alexey Demakov
ISP RAS http://www.ispras.ru
RedVerst Group http://www.unitesk.com







 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 





More information about the antlr-interest mailing list