I have a lexer rule listing all the acceptable symbols:
ALL_SYMBOLS: ('!' | '#' | '%' | '^' | '-' | '+' | '=' | '<' | '>' | ',' |
'.' |'?' | '/' | '*' ); // and more......
But sometimes I also want a parser rule to match all symbols except say "! #",
"+ =" or "+ - * /". Because I have different needs at different time, I want
to specify a rule using ALL_SYMBOLS minus some symbols style. How should one
write such a rule? Can semantic predicate achieve this?
I've never used semantic predicate before. Are these the proper way to use it:
all_symbols_except_hash_equal: ALL_SYMBOLS {"#=".indexOf($text)< 0 }? ; // can
it be done this way? Can $text be used inside a semantic predicate?
all_symbols_except_comma_plus_minus: {",+-".indexOf($text) < 0}?=>ALL_SYMBOLS ;
// or should it be done this way? But $text seems not available inside a
predicate and there is an failed predicate exception message printed in the
screen
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
--
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.