I am trying to write a grammar to parse SQL where clause expression, And facing problem with Lexical rule to identify unique identifier. My grammar is like-
grammar Sample;
UID: '^[A-Za-z0-9]{8}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{12}$';
literal_value :
UID
;
And my code to parse is-
public void compile() {
String expression = "4B66049D-6E1A-4CE6-8FBF-B31CD8B9E6AF"
ANTLRInputStream input = new ANTLRInputStream(expression);
SampleLexer lexer = new SampleLexer(input);
final CommonTokenStream tokens = new CommonTokenStream(lexer);
SampleParser parser = new SampleParser(tokens);
SampleParser.Literal_valueContext context = parser.literal_value();
System.out.println(context.toStringTree());
}
But I am getting error - Exception parsing expression: 'token recognition error at: '4'' on line 1, position 0