That is telling you that err, you can't use rewrite syntax AND an operator ;). Which one is it supposed to use?
So, remove any ^ and ! operators from the rule and use rewrite rules only. However, is that what you want to rewrite it as. I think you are using query_expression as that was what it looked like in v2. You might be better off abstracting in to two rules: queryExpression : unionExpressions -> ^(QUERY_EXPRESSION unionExpressions) ; unionExpressions : query_term (( "union"^ | "except"^ ) "all"? query_term)* ; However, using lower case literals in your parser directly is not a good idea. Use real tokens so that you error messages are better and remember that SQL is generally case insensitive so you will need a [trivial] custom input stream. Jim > -----Original Message----- > From: antlr-interest-boun...@antlr.org [mailto:antlr-interest- > boun...@antlr.org] On Behalf Of Ruslan Zasukhin > Sent: Tuesday, March 22, 2011 11:12 AM > To: Matt Fowles > Cc: antlr-interest@antlr.org; Michail Kropivka > Subject: Re: [antlr-interest] Q: move from v2 to v3 parser grammar. > Rewrite tree rule > > On 3/20/11 1:11 PM, "Matt Fowles" <matt.fow...@gmail.com> wrote: > > Hi Matt, > > > Ruslan, > > > Try: > > > > query_expression > > : query_term (( "union" | "except" )^ "all"? query_term)* > > -> ^(QUERY_EXPRESSION $query_expression) > > ; > > Well, $ not helps. Still same > error 165 uses rewrite syntax and also an ast operator > > As I understand, > -> is re-write syntax > ^ is AST operator ... > > > > > Matt > > > > On Sun, Mar 20, 2011 at 10:40 AM, Ruslan Zasukhin > > <ruslan_zasuk...@valentina-db.com> wrote: > >> Hi All, > >> > >> In v2 grammar we have rule as > >> > >> =========================================== > >> query_expression > >> : query_term (( "union"^ | "except"^ ) ( "all" )? query_term)* > >> { ## = #([QUERY_EXPRESSION,"QUERY_EXPRESSION"], ##); } > >> ; > >> =========================================== > >> > >> > >> We try change it to v3 > >> > >> =========================================== > >> query_expression > >> : query_term (( "union"^ | "except"^ ) ( "all" )? query_term)* > >> ->(QUERY_EXPRESSION ???? ) > >> ; > >> =========================================== > >> > >> Ops, we cannot specify top node, because it can be union OR except. > >> > >> > >> For now the only way we have found is: > >> =========================================== > >> query_expression > >> : query_expression2 ->(QUERY_EXPRESSION query_expression2) > >> ; > >> > >> > >> query_expression2 > >> : query_term (( "union"^ | "except"^ ) ( "all" )? query_term)* > >> ; > >> =========================================== > >> > >> > >> > >> Question is. May be exists more elegant way for v3 Without > additional > >> rule? > > > -- > Best regards, > > Ruslan Zasukhin > VP Engineering and New Technology > Paradigma Software, Inc > > Valentina - Joining Worlds of Information http://www.paradigmasoft.com > > [I feel the need: the need for speed] > > > > List: http://www.antlr.org/mailman/listinfo/antlr-interest > Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your- > email-address 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 il-antlr-inter...@googlegroups.com. To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.