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.
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.