In the language I’m grammaring here, I want to allow custom operator definitions whose identifiers fall into the Unicode categories S,P,Me but exclude the below bracketing chars and comma:
<code>// Punctuation
L_PAREN : '(';
R_PAREN : ')';
L_CURLY : '{';
R_CURLY : '}';
L_BRACKET : '[';
R_BRACKET : ']';
COMMA : ',';
// Operator Identifiers
NO_OP : (L_PAREN | R_PAREN | L_BRACKET | R_BRACKET | L_CURLY | R_CURLY | COMMA);
IDENT_OP_LIKE : (UNICODE_OPISH ~NO_OP)+;
fragment UNICODE_OPISH : [p{S}p{P}p{Me}];
</code>
<code>// Punctuation
L_PAREN : '(';
R_PAREN : ')';
L_CURLY : '{';
R_CURLY : '}';
L_BRACKET : '[';
R_BRACKET : ']';
COMMA : ',';
// Operator Identifiers
NO_OP : (L_PAREN | R_PAREN | L_BRACKET | R_BRACKET | L_CURLY | R_CURLY | COMMA);
IDENT_OP_LIKE : (UNICODE_OPISH ~NO_OP)+;
fragment UNICODE_OPISH : [p{S}p{P}p{Me}];
</code>
// Punctuation
L_PAREN : '(';
R_PAREN : ')';
L_CURLY : '{';
R_CURLY : '}';
L_BRACKET : '[';
R_BRACKET : ']';
COMMA : ',';
// Operator Identifiers
NO_OP : (L_PAREN | R_PAREN | L_BRACKET | R_BRACKET | L_CURLY | R_CURLY | COMMA);
IDENT_OP_LIKE : (UNICODE_OPISH ~NO_OP)+;
fragment UNICODE_OPISH : [p{S}p{P}p{Me}];
but the ~NO_OP
part of IDENT_OP_LIKE
errors with: “rule reference NO_OP is not currently supported in a set” but I guess I’m just mistaken in my idea of how to express this exclusion-from-set.
Is there any better / supported way to express this in one’s Antlr4 Lexers?