0

I have grammar:

grammar qwe;

query
    : COLUMN OPERATOR value EOF
    ;

COLUMN
    : [a-z_]+
    ;

OPERATOR
    : ('='|'>'|'<')
    ;

STRING_LITERAL
    : [a-zA-Z_]+
    ;

value
    : STRING_LITERAL
    ;

WS : [ \t\r\n]+ -> skip ;

Example query: total_sales>qwe.

The problem with that is that COLUMN and value lexer rules are identical. This causes errors:

enter image description here

How could I rewrite the grammar to make it work without error messages?

1 Answers1

1

You can't have two equal lexer rules, of course. In this case it seems that you should remove the COLUMN rule and treat it as a value, if there's really nothing that distinguishes them.

Another option would be to consider a rule for COLUMN with a number of reserved words, if that's applicable.

bwdm
  • 793
  • 7
  • 17