[antlr-interest] How to easily parse a language into a tree ?
weberjn <weberjn at yahoo.com>
weberjn at yahoo.com
Thu Jan 23 08:25:32 PST 2003
I am trying to parse an IDL (using the grammar in the antlr package)
to extract struct information into a data structure I can work with.
First I tried buildAST=true;
but the resulting linked list does not really help me.
Second I thought of using a tree grammar, but the way to do that seems
difficult and as I userstand, I have to write an additional tree
grammar.
So I started including semantic predicates into the existing IDL
grammar:
member returns [ Member m ]
{ m=new Member();
LinkedList l=new LinkedList(); String s;}
: s=type_spec { m.type_spec=s; } declarators[l] { m.declarators=l;
}SEMI;
where Member is a user class. Basically this would be a tree with
Collections as containers and user defined classes as knodes.
I wonder if this is the most easy way? As it seems it is a lot of work
and clutters the grammar.
Thank you,
Juergen
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list