// Take care of whitespace.
WS : [ \r\t\f\n]+ -> skip;
OTHER: . -> skip;
STRING
: '"' [A-z ]+ '"'
;
evaluate // starting rule.
: textbox? // could be an empty textbox.
;
textbox
: (row '\n')*
;
row
: ability
| ability_list
ability
: activated_ability
| triggered_ability
| static_ability
triggered_ability
: trigger_words ',' STRING
;
trigger_words
: ('when'|'whenever'|'as') whenever_triggers|'at'
;
whenever_triggers
: triggerer (('or'|'and') triggerer)* // this line has the issue.
;
triggerer
: self
self: '~'
I pass it this text: whenever ~ or ~
, and it fails on the or
, saying line 1:10 mismatched input ' or' expecting {'or', 'and'}
. However, if I add a space to the whenever_triggers
rule's or
string (making it ' or'|'and'
), it works fine.
The weirdest thing is that if I try whenever ~ and ~
, it works fine even without the rule having a space in the and
string. This doesn't change if I make 'and'|'or'
a lexer rule either. It's just bizarre. I've confirmed this bug happens when running the 'test rig' in Antlrworks 2, so it's not just an IntelliJ thing. I've checked, and I'm using the latest 4.7 version in the IntelliJ plugin.
I've attached an image of the parse tree I get when this error occurs.
I'm using the ANTLR 4 plugin in IntelliJ, and I have the most bizarre bug. I'll start with the relevant parser/lexer rules:
Yep, turns out I had another rule that had ' or' defined in it. I've since learned that implicit tokens are bad, so I'm going to go through my grammar and tokenize everything in its own lexer rules. I'm also going to put all my catch-all rules (like STRING, which is only temporary, and OTHER, at the end).
--
You received this message because you are subscribed to the Google Groups "antlr-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to antlr-discussi...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I think that the real problem is the use of ' or' rather than 'or'. Including the space causes conflicts with WS.
--
You received this message because you are subscribed to the Google Groups "antlr-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to antlr-discussi...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.