classafPegger::Peg
sys::Obj afPegger::Peg
@
Js
Parsing Expression Grammar (PEG)
- contains
Bool contains()
Returns
true
if the string contains a rule match. Convenience for:search != null
- debugOn
static Void debugOn(Bool debug := true)
Turns debug messaging on and off.
- each
Calls the given function for each rule match found in the string.
- eachWhile
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
Creates a PEG class ready to match the given string and rule.
- makePattern
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
Match? match()
Runs the PEG rule against the string.
- matched
Str? matched()
Runs the PEG rule against the string. Returns the matched string.
- matches
Bool matches()
Runs the PEG rule against the string. Returns
true
if it matches.- parseGrammar
static Grammar parseGrammar(Str grammar)
Parses a list of grammar definitions. For example:
parseGrammar("a <- [abc] / [xyz] / b b <- \space+ [^abc]")
- parseRule
- pegGrammar
static Grammar pegGrammar()
Returns the grammar PEG used to parse PEG grammar.
It's not particularly useful, but it may be interesting to some.
- search
Str? search(Str? label := null, Int? offset := null)
Searches for the next match and returns the matched string (if any).