Warning: This is the manual of the legacy Guile 2.2 series. You may want to read the manual of the current stable series instead.
Next: PEG API Reference, Up: PEG Parsing [Contents][Index]
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.
"a b"
(and a b)
Parses a. If this fails, backtracks and parses b. Succeeds if either a or b succeeds.
"a/b"
(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.
"a*"
(* a)
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.
"a+"
(+ a)
Tries to parse a. Succeeds if a succeeds.
"a?"
(? a)
Makes sure it is possible to parse a, but does not actually parse it. Succeeds if a would succeed.
"&a"
(followed-by a)
Makes sure it is impossible to parse a, but does not actually parse it. Succeeds if a would fail.
"!a"
(not-followed-by a)
Parses the string "abc". Succeeds if that parsing succeeds.
"'abc'"
"abc"
Parses any single character. Succeeds unless there is no more text to be parsed.
"."
peg-any
Alternative syntax for “Ordered Choice a b” if a and b are characters.
"[ab]"
(or "a" "b")
Parses any character falling between a and z.
"[a-z]"
(range #\a #\z)
Example:
"(a !b / c &d*) 'e'+"
Would be:
(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.
Example:
"!a / 'b'"
Is equivalent to
(or (peg "!a") "b")
and
(or (not-followed-by a) "b")
Next: PEG API Reference, Up: PEG Parsing [Contents][Index]