Closed Baozi2 closed 1 year ago
rule(:sgt) { (str('EU') >> (str('RO') | str('R')).maybe).as(:sgt) }
works. In general, alternation and 'maybe' will never interact constructively; one says that either of A or B should be parsed - the other says that A might be empty. If A is empty, the first branch of the alternation will always be accepted.
This is still a ratpack parser, with all the downsides. The upside is that behaviour is predictable.
This is my code, why the rule sgt can used for EURO, cannot used for EUR? Thanks