I'm writing a grammar for parsing PlantUML State diagrams and have the following doubt:
I had:
transition: STATE arrow STATE (":" event? guard? action?)? "\n"
arrow: ("->" | "-->" | "-left->" | "-right->" | "-up->" | "-down->")
But had to change to:
transition: STATE ("->" | "-->" | "-left->" | "-right->" | "-up->" | "-down->") STATE (":" event? GUARD? action?)? "\n"
Because, for my application, I don't need nor care which type of arrow is used; it is sufficient to know that an arrow was there to form the transition.
The question is: Is there a way to split the transition
rule in other more manageable rules without the arrow type appearing in the parsed tree?
Full file at https://github.com/thomedes/PlantUML-Lark-EBNF. Feel free to comment / criticize. Trying to learn here
After RTFM, I've found that terminals whose name begins with underscore are not output to the tree, so I've changed it to:
And now it works fine.
Not marking this as an accepted answer because I'm sure someone with more experience could give a better answer.