[antlr-interest] ANTLR3.0b5 - Embedding on parser within another one (Parser nesting)
alexander.berger at finnova.ch
alexander.berger at finnova.ch
Tue Nov 28 07:17:07 PST 2006
Hi
I have two parsers and want to embed on parser within the other. But somehow
I don't get it. I expected it to work like this:
start :
x=subParser -> $x.expression
;
subParser returns [Expression expression] :
'do' {
PLangParser p = new PLangParser(this.getTokenStream());
p.setTreeAdaptor(this.getTreeAdaptor());
$subParser.expression = (Expression)p.start().getTree(); }
;
but in the rewrite instruction '-> $x.expression' antlr complains with the following error message:
error(100): PLang.g3:111:19: syntax error: antlr: PLang.g3:111:19: unexpected token: .
In other words, in the rewrite instruction "x=subParser -> $x.expression"
antlr does not allow to use the return value as output Tree.
I haven't found a solution on the WIKI page so I am curious if this kind
of parser embedding is possible or not with antlr3.
Has anybody ever tried to do something similar?
Kind regards
Alex
____________________________________________
finnova AG Bankware
Alexander Berger
SR-Peripheral-Team
Sägestrasse 22, CH-5600 Lenzburg
Tel: +41 62 886 4807 / Fax: +41 62 886 4888 mailto:alexander.berger at finnova.ch
http://www.finnova.ch
More information about the antlr-interest
mailing list