classafPegger::Peg

sys::Obj
  afPegger::Peg

@Js

Parsing Expression Grammar (PEG)

contains

Source

Bool contains()

Returns true if the string contains a rule match. Convenience for:

search != null
debugOn

Source

static Void debugOn(Bool debug := true)

Turns debug messaging on and off.

each

Source

Void each(|Match fn)

Calls the given function for each rule match found in the string.

eachWhile

Source

Obj? eachWhile(|Match->Obj? fn)

Calls the given function for each rule match found, until a non-null result is returned. If there are no matches, null is returned.

make

Source

new make(Str str, Rule rule)

Creates a PEG class ready to match the given string and rule.

makePattern

Source

new makePattern(Str str, Str pattern)

Parses the given PEG pattern in to a rule. Convenience for:

Peg(str, Peg.parsePattern(pattern))

See Rule.parseRule

match

Source

Match? match()

Runs the PEG rule against the string.

matched

Source

Str? matched()

Runs the PEG rule against the string. Returns the matched string.

matches

Source

Bool matches()

Runs the PEG rule against the string. Returns true if it matches.

parseGrammar

Source

static Grammar parseGrammar(Str grammar)

Parses a list of grammar definitions. For example:

parseGrammar("a <- [abc] / [xyz] / b
              b <- \space+ [^abc]")

See Grammar.parseGrammar

parseRule

Source

static Rule parseRule(Str pattern)

Parses a pattern in to simple rule. For example:

parseRule("[abc] / [xyz]")

See Rule.parseRule

pegGrammar

Source

static Grammar pegGrammar()

Returns the grammar PEG uses to parse PEG grammar.

It's not particularly useful, but it may be interesting to some.

Source

Str? search(Int? offset := null)

Searches for the next match and returns the matched string (if any).