Hi I am trying to parse a sip Uri using antlr4. For the time being I have strip off the complexity to keep the question simple
Antlr4 Grammar
sipUri : SIP_SCHEME coreUri EOF ;
coreUri : USER_INFO? hostPort ;
hostPort : 'abc.com' ;
SIP_SCHEME : 'sip:';
USER_INFO : USER PASSWORD? '@' ;
fragment USER : ALPHA_NUM+ ;
fragment PASSWORD : ':' ALPHA_NUM+ ;
fragment ALPHA_NUM : ALPHA | DIGIT ;
fragment ALPHA : ('a'..'z' | 'A'..'Z') ;
fragment DIGIT : ('0'..'9') ;
String Input 1 : sip:user:[email protected]
String Input2 : sip:[email protected]
In second input, "sip" was parsed as USER and "user" was parsed as PASSWORD, since "sip" qualifies to be a USER/PASSWORD as per grammar.
Hope I described my problem. Don't know how to proceed now in this situation?