I have a grammar for parsing diverse SQL code.
Problem :
- sometimes, I want it to handle nested comments (ex: Microsoft SQL):
COMMENT: '/*' (COMMENT|.)*? ('*/' | EOF) -> channel(HIDDEN);
- sometimes, I want it to not handle them (ex: Oracle):
COMMENT: '/*' .*? '*/' -> channel(HIDDEN);
I don't want to :
make two different grammars
compile my grammar twice to get two different lexers and two different parsers.
Best solution would be to have an argument, passed to the lexer/parser, to choose which "COMMENT implementation" to use.
Can I do this ? If yes, how, if not, is there a satisfying solution to my problem ?
Thanks !