Regarding the following reduced grammar
proof_command : 'Proof' 'using' collection '.';
collection : 'Collection' IDENT ':=' section_subset_expr
| 'Collection' KeySOME ':=' IDENT IDENT IDENT
;
KeySOME : 'Some';
(wherease IDENT is just a usual identifier as in Java) i am trying to parse the following : Proof using Collection Some := a b c .
This doesn't work and results in the following Error message:
mismatched input 'a' expecting 'section_subset_expr'
This is because IDENT can of course also be 'Some' .
Is there a way to use Some as a keyword and as an Identifier, so the expression above gets parsed correctly? Maybe through a semantic predicate excluding 'Some' from IDENT in the collection rule? But how would that look like?
IDENT : IDENT2;
fragment IDENT2 : FIRST_LETTER (SUBSEQUENT_LETTER)*;
fragment FIRST_LETTER : [a-z] | [A-Z] | '_' | UNICODE_LETTER;
fragment SUBSEQUENT_LETTER : [a-z] | [A-Z] | DIGIT | '_' | '"' | '\''| UNICODE_LETTER | UNICODE_ID_PART;
fragment UNICODE_LETTER : '\\' 'u' HEX HEX HEX HEX;
fragment UNICODE_ID_PART : '\\' 'u' HEX HEX HEX HEX;
fragment HEX : [0-9a-fA-F];
KeySOME : 'Some';