Any rule element separated by a pipe character (|) is considered a
choice. Choices are matched against the input stream in order. If a match succeeds then the remaining choices are discarded and the result of the match is the AST result of the choice.
ExamplesUSING: prettyprint peg.ebnf ;
"a" EBNF[[ rule="a" | "b" | "c" ]] .
"a"
USING: prettyprint peg.ebnf ;
"b" EBNF[[ rule="a" | "b" | "c" ]] .
"b"
USING: prettyprint peg.ebnf ;
"d" EBNF[[ rule="a" | "b" | "c" ]] .
Peg parsing error at character position 0.
Expected 'a' or 'b' or 'c'
Got 'd'
NotesDue to parser caching, rules can't re-use parsers that have already failed earlier in the choice.