[antlr-interest] Re: error in my rule...
micheal_jor <open.zone at virgin.net>
open.zone at virgin.net
Wed Dec 11 05:14:41 PST 2002
> Could you help me to understand what is wrong in my rule:
>
> query!
> :SELECT! a:selection_list
> {## = #([QUERY, "query"], #(SELECT, a));}
> (WHERE! b:where_list
> {## = #([QUERY, "query"], #(SELECT, a),#(WHERE, b));})?
> ;
>
> As output I want to get an AST of the form:
> #(QUERY #(SELECT a) #(WHERE b)), where
> QUERY is imaginary note and WHERE is optional.
>
> How could I rewrite this rule?
Your sample above could be rewritten as shown below (unlabelled rule
references don't work properly if memory serves):
query!
: s:SELECT! a:selection_list
{ ## = #([QUERY, "query"], #(#s, a)); }
( w:WHERE! b:where_list
{ ## = #([QUERY, "query"], #(#s, a), #(#w, b)); }
)?
;
Cheers!,
Micheal
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list