Hi,
I am trying to parse the following input:
[
MSG1:
MSG2: cmd1 cmd2
MSG3: cmd3
]
which means on MSG1 and MSG2 commands cmd1 and cmd2 should be executed, on
MSG3 the command cmd3 should be executed.
I tried the following grammar:
grammar msg_test;
msg_list: LSQUARE msg_impl* RSQUARE ;
msg_impl: (ID COLON)+ stmnt* ;
stmnt : ID | INT ;
LSQUARE : '[' ;
RSQUARE : ']' ;
COLON : ':' ;
ID : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')*;
INT : '0'..'9'+;
WS : ( ' ' | '\t' | '\r' | '\n' ) {$channel=HIDDEN;};
But this results in the following warning:
[10:59:35] warning(200): msg_test.g:3:20: Decision can match input such as
"ID" using multiple alternatives: 1, 2
When I run the parser I get a MismatchedTokenException on cmd2.
When changing msg_impl by removing + to
msg_impl: (ID COLON) stmnt* ;
the parser works fine (no warnings, the input is being parsed), but the
"connection" between MSG1 and MSG2 is lost and I cannot create an AST-Node
containing all messages that should be handled the same way.
It seems as if the COLON is not used in the stmnt* lookahead part to break
out of the loop. Why? Can I force it somehow?
Thanks for help and best regards
Christian
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address