[antlr-interest] Two Questions on Tree Generating Parsers

Marco Ladermann ladermann at hbg.dpa.de
Fri Jul 11 00:26:57 PDT 2003


Hi,

while building a tree generating parser, I'm struggling with the problem of 
replacing the nodes of a subrule with one single custom (heterogeneous) node.
(A b c D)* should be aggregated to (MyNode[A, b, c, D])*. Here the notation 
MyNode[A, b, c, D] means that MyNode depends in someway on the original 
nodes.

My first attemt was to shut off the automatic tree generation for that subrule 
(! A b c D { action } )*, but I found no obvious macro to get my node 
appended to the currentAST in "action". The only workaraund I found was:
(A! b! c! d:D<AST=MyNode> { action on d })*, which looks quite ugly and ad 
hoc.

Does someone have an idea to to do this a little bit more elegant?

During my experiments with which grammar produces which code, I found that the 
tree generating code is *not* guarded by "if (inputState.guessing == 0)". I 
didn't test it, but I was wondering if that can do any harm to the parser, 
when using syntactic lookahead?

Greetings
Marco
-- 


 

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




More information about the antlr-interest mailing list