java - ANTLR Parser matching token not identifier -



java - ANTLR Parser matching token not identifier -

i writing parser sql statements. defined tokens keywords like:

tokens { create = 'create'; table = 'table'; year = 'year'; name = 'name'; ... }

and identifier as

identifier : ( letter | '_' ) (namechar)* ; real_number : number_value ( 'e' ( plus | minus )? digit )? ; fragment number_value : {numberdotvalid()}?=> digit dot digit? | dot digit | digit ; fragment namechar : letter | digit | '.' | '-' | '_' |'%' ; fragment digit : '0' .. '9' ( '0' .. '9' )* ; fragment letter : 'a'..'z' | 'a'..'z' ;

i have passed input as:

create table emp (table smallint not nulll);

i got error mismatched input expecting identifier. error on (table smallint...) part. know tokens precedence higher parser rules , matching token table. right way handle such types of issues?

please help.

i guess beacuse token 'table' different 'table' recognized identifier, note uppercase 't' tokens not same, create like:

table : 'table' | 'table' | 'table';

or avoid combinations of upper , lower cases, like:

table: table; fragment t: 't' | 't'; fragment a: 'a' | 'a';

and on, that's approach used antlr too

java antlr3

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -