[antlr-interest] substitution for a node during parsing
Alex
alex_apac at yahoo.fr
Thu Jul 14 16:40:01 PDT 2005
Hello,
I'm sure I'm missing something that I didn't get while reading the doc.
If someone can give me hint on what I do wrong.
I wanted to substitute the SLASH node for a custom one. (SLASH:'/';)
excerpt from the text I scan text:
area-specifier / service-provider / future-extension
the rule with a standard AST for SLASH:
alternation : concatenation ( SLASH^ concatenation )* ;
and the result tree:
"/"
|-> "/"
| |-> area-specifier
| |-> service-provider
|-> future-extension
now when I try to have a "custom" node instead of SLASH I wanted the type ALTERNATION
I have a slightly different output I hacked something after glancing at the generated code.
alternation : concatenation ( !a:SLASH b:concatenation {
#a=#([ALTERNATION,"ALT|"],#b);
astFactory.makeASTRoot(currentAST, #a);
} )*
;
And the swapped result tree:
"ALT/"
|-> future-extension
|-> "ALT/"
|-> service-provider
|-> area-specifier
Thanks
/Alex
___________________________________________________________________________
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
Téléchargez cette version sur http://fr.messenger.yahoo.com
More information about the antlr-interest
mailing list