I created a sample grammer and generated java source codes and compile them and executed my sample grammer but I got an error like the below.
C:\devEnvironments\antlr>java org.antlr.v4.runtime.misc.TestRig mytest.RuleTest
column_spec -tree
aaa.bbb.ccc
^Z
line 1:0 no viable alternative at input 'aaa.bbb.ccc\r\n'
(column_spec aaa.bbb.ccc\r\n)
The following is my rule source code.
grammar RuleTest;
@header {
package mytest;
}
column_spec:
( ( schema_name DOT )? table_name DOT )? column_name ;
ID:
( 'A'..'Z' | 'a'..'z' | '_' | '$') ( 'A'..'Z' | 'a'..'z' | '_' | '$' | '0'..'9' )*
;
// identifiers --- http://dev.mysql.com/doc/refman/5.6/en/identifiers.html --------------
schema_name : ID;
table_name : ID;
engine_name : ID;
column_name : ID;
view_name : ID;
parser_name : ID;
index_name : ID;
partition_name : ID;
partition_logical_name : ID;
constraint_symbol_name : ID;
foreign_key_symbol_name : ID;
collation_name : ID;
event_name : ID;
user_name : ID;
function_name : ID;
procedure_name : ID;
server_name : ID;
wrapper_name : ID;
alias : ( AS_SYM )? ANY_STRING;
ANY_STRING:
~(' ')+;
DOT : '.' ;
AS_SYM : 'as';
WS : [ \t\r\n]+ -> skip ;
I don't know why '\r', '\n' characters are not skipped and why this error happens? I used antlr 4.4 version.