[antlr-interest] looking for rewrite rule - (UNION | EXCEPT)^ ALL? put in one token
S.Eifert
athavar at web.de
Tue Jul 27 09:39:16 PDT 2010
Hello,
thanks for the input, jbb.
What I got now is the following:
tokens{
UNIONALL;
EXCEPTALL;
}
query_exp
: query_term ((UNION | EXCEPT | UNIONALL | EXCEPTALL)^ query_term)*
;
UNION : U N I O N (WS A L L { $type=UNIONALL; } )? ;
WS : (' ' | '\t' | '\n' | '\r')+ {$channel = HIDDEN;};
This construction almost works. For parsing a sentence with UNION ALL the
result is correct. When I try to use just UNION like "select * from table1
UNION select * from table2;" I get an error "mismatched character 's'
expecting set null". If I understand correctly it has something to do with
the whitespaces behind the UNION. When I change the UNION lexical rule to
UNION : U N I O N WS (A L L { $type=UNIONALL; } )? ;
it kind of works. Using Space as a whitespace seems to work. Using a newline
changes the type of the token to "UNION/n/r". Maybe someone has an idea what
I'm overlooking here.
As a side node: Yes, if I was the one responsible for the whole grammar I
would have used an extra rule to split unionstuff into UNION and UNIONALL.
But I cannot put this information one child down in the tree. That's how the
stuff was implemented before i came to the project. UNION or UNIONALL has to
be at the exact position in the tree.
Cheers and thanks for the help so far
Sandro
--
View this message in context: http://antlr.1301665.n2.nabble.com/looking-for-rewrite-rule-UNION-EXCEPT-ALL-put-in-one-token-tp5338034p5342977.html
Sent from the ANTLR mailing list archive at Nabble.com.
More information about the antlr-interest
mailing list