I\'m trying to parse a simple subset of SQL using antlr4.
My grammar looks like this:
grammar Query;
query : select;
select : \'select\' colname (\',
You cannot have two lexer rules that match the same (at least, not in the same mode/state...):
...
COLNAME: [a-z]+ ;
TABLENAME : [a-z]+;
...
Do this instead:
grammar Query;
query : select;
select : 'select' colname (',' colname)* 'from' tablename;
colname : ID;
tablename : ID;
ID : [a-z]+;
WS : [ \t\n\r]+ -> skip;