Parses a. If this succeeds, continues to parse b from the end of the text parsed as a. Succeeds if both a and b succeed.
(and a b)
Parses a. If this fails, backtracks and parses b. Succeeds if either a or b succeeds.
(or a b)
Parses a as many times in a row as it can, starting each a at the end of the text parsed by the previous a. Always succeeds.
Parses a as many times in a row as it can, starting each a at the end of the text parsed by the previous a. Succeeds if at least one a was parsed.
Tries to parse a. Succeeds if a succeeds.
Makes sure it is possible to parse a, but does not actually parse it. Succeeds if a would succeed.
Makes sure it is impossible to parse a, but does not actually parse it. Succeeds if a would fail.
Parses the string "abc". Succeeds if that parsing succeeds.
Parses any single character. Succeeds unless there is no more text to be parsed.
Alternative syntax for “Ordered Choice a b” if a and b are characters.
(or "a" "b")
Parses any character falling between a and z.
(range #\a #\z)
"(a !b / c &d*) 'e'+"
(and (or (and a (not-followed-by b)) (and c (followed-by (* d)))) (+ "e"))
There is some extra syntax for S-expressions.
Ignore the text matching a
Capture the text matching a.
Embed the PEG pattern a using string syntax.
"!a / 'b'"
Is equivalent to
(or (peg "!a") "b")
(or (not-followed-by a) "b")