[antlr-interest] Need an an example of intermediate level to learn

Alexey Demakov demakov at ispras.ru
Mon Sep 12 00:23:44 PDT 2005


Hi,

Whould you like to look at my parser?
It is for rather simple language
(BNF: http://cvs.sourceforge.net/viewcvs.py/treedl/TreeDL/treedl/src/bnf/TreeDL.bnf?view=markup )
(ANTLR lexer/parser: http://cvs.sourceforge.net/viewcvs.py/treedl/TreeDL/treedl/src/java/com/unitesk/atp/treedl/TDL.g?view=markup )
Almost all parser rules are simple, however there are some lookaheads.
Parser rules create nodes of strictly-typed heterogenous tree.
Nodes are created using factory to be able to cancel tree creation after syntax errors.
The most complicated part is embedded blocks written in different language.
These blocks are analyzed by lexers specified in input program itself
(like ANTLR 'language' file option)
(Default ANTLR lexer for embedded code:
http://cvs.sourceforge.net/viewcvs.py/treedl/TreeDL/treedl/src/java/com/unitesk/atp/treedl/CODE.g?view=markup )
So, token stream switching (multiplexing) is used.
Real examples written in this language: http://treedl.sourceforge.net/examples.html
I think that this example can be understood after learning of ANTLR basics.
And it should be useful - many questions in this list I answered simple copy/paste some parts of this lexers/parser :)
There are not many comments/descriptions but I hope code is self-documented.
In any case, you can mail me any questions about it.

Regards,
Alexey

-----
Alexey Demakov
TreeDL: Tree Description Language: http://treedl.sourceforge.net
RedVerst Group: http://www.unitesk.com

----- Original Message ----- 
From: "Nagesh, Harsha" <harsha.nagesh at csfb.com>
To: <antlr-interest at antlr.org>
Sent: Sunday, September 11, 2005 3:28 AM
Subject: [antlr-interest] Need an an example of intermediate level to learn


>
> Hi,
>
>    Can somebody please point me to an antlr based example with reasonably
> complicated rules of parser action/language transformation ?
>
> I have gone through ALL the calculator examples, the CSV to HTML convertor
> and a couple of others which I could get from the beginners section of
> antlr.org. But I am unable to find more conplicated rules and parser action
> and the online documentation is too abstract. Learning by example is far
> easier.
>
> Also, if the mailing list archive could be searched it would make life much
> simpler.
>
> Thanks for your help,
> Harsha
>
> ==============================================================================
> Please access the attached hyperlink for an important electronic communications disclaimer:
>
> http://www.csfb.com/legal_terms/disclaimer_external_email.shtml
>
> ==============================================================================
>



More information about the antlr-interest mailing list