[antlr-interest] meaning of #xxx
Kevin J. Cummings
cummings at kjchome.homeip.net
Thu May 12 14:14:02 PDT 2011
On 05/12/2011 10:51 AM, Philippe Frankson wrote:
> Hi,
> In a grammar done with ANTLR 2.x, I have seen the following expression:
>
> sql_literal:
> ( NUMBER | QUOTED_STRING | "null" )
> { #sql_literal = #([SQL_LITERAL, "sql_literal"], #sql_literal);
> }
> ;
>
> Anybody can explain the meaning of the code inside the { } ? (or send a
> link where I can find the doc).
You should read the documentation. Its all explained in the "ANTLR
Reference Manual".
{} surround action blocks. Code from the target language that should be
executed after the previous rule (or sub-rule) was matched.
> #sql_literal ?
#ruleName is the resulting AST tree. In this case, for the rule being
executed. In this case, it sets the AST for this rule to what's on the RHS.
> #(x,y) ?
This is AST construction. What's in the []'s is a token creation of the
form [TOKEN_TYPE, token_spelling]
> I could not find relevant documentation explaining that.
Start here:
http://www.antlr2.org/doc/index.html
There is lots of documentation on the ANTLR V2 site....
> Thx a lot.
> Philippe
--
Kevin J. Cummings
kjchome at verizon.net
cummings at kjchome.homeip.net
cummings at kjc386.framingham.ma.us
Registered Linux User #1232 (http://counter.li.org)
More information about the antlr-interest
mailing list