[antlr-interest] action syntax - "#"
Stanimir Stamenkov
stanio at myrealbox.com
Tue Mar 7 23:09:53 PST 2006
/frank uno/:
> We are unable to find any documentation for the symbol
> - "#" used in the action syntax part.
From the ANTLR Reference Manual:
ANTLR Tree Construction <http://www.antlr.org/doc/trees.html>
> For Example:
>
> quantifiedInVarBinding throws XPathException
> { String varName; }:
> DOLLAR! varName=qName! ( typeDeclaration )? "in"!
> exprSingle
> { #quantifiedInVarBinding = #(#[VARIABLE_BINDING,
> varName], #quantifiedInVarBinding); }
> ;
I guess you need something like:
quantifiedInVarBinding throws XPathException
{ String varName; }:
DOLLAR! varName:qName! ( typeDeclaration )? "in"!
exprSingle
{ #quantifiedInVarBinding = #([VARIABLE_BINDING,
varName], quantifiedInVarBinding); }
;
Something I haven't actually got from the documentation is the exact
syntax:
#(A, B, C)
i.e. separating the tokens with commas. In the documentation there
are examples without commas, like:
> stat:
> ID EQUALS^ expr // auto construction
> ... some alternatives ...
> |! RETURN expr
> {#stat = #([IMAGINARY_TOKEN_TYPE] expr);}
> ... more alternatives ...
> ;
but this gives me an error running the ANTLR tool. There is example
using a comma, too:
> decl : ( TYPE ID )+
> { #decl = #([DECL,"decl"], #decl); }
> ;
but this one is slightly different as it creates one more tree
branch (if it matters at all).
--
Stanimir
More information about the antlr-interest
mailing list