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
[email protected]
[email protected]
[email protected]
Registered Linux User #1232 (http://counter.li.org)

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to