I am doing an ANTLR specification. In my AST i need to do this one:
characters ('*'^|'+'^|'?'^)?
I need to do a rewrite rule that will present in ast instead of * ASTERISK, instead of + PLUS and instead of ? QMARK nodes?
I know that if we would have something like this:
characters '*'
it can be rewrited as
^(ASTERISK characters)
but i dont know how to deal with | operator?
Try this:
The key here is that if the optional
*,+or?are not present, thecharacterswill just staycharactersby the rewrite rule:(characters -> characters).