EBNF Rule: Option
EBNF

Prev:EBNF Rule: Ignore
Next:EBNF Rule: One or more


Any rule element followed by a question mark (?) is considered optional. The rule is tested against the input. If it succeeds the result is stored in the AST. If it fails then the parse still succeeds and false (f) is stored in the AST.

Examples
USING: prettyprint peg.ebnf ; "abc" EBNF[[ rule="a" "b"? "c" ]] .
V{ "a" "b" "c" }

USING: prettyprint peg.ebnf ; "ac" EBNF[[ rule="a" "b"? "c" ]] .
V{ "a" f "c" }