classafPegger::Match

sys::Obj
  afPegger::Match

@Js

Represents a PEG match result.

contains

Source

Bool contains(Str label)

Returns true if a there's a direct sub-match with the given rule label or name.

data

Source

[Str:Obj?]? data

Storage for user data - use when investigating match results.

debugStr

Source

Str debugStr()

Returns the matched tree as a string.

dump

Source

This dump(OutStream out := Env.cur().out())

Dumps the matched tree to std-out. Useful for debugging.

findMatch

Source

Match? findMatch(Str label, Int index := 0)

Deeply searches for a labelled Match of the given name at the given index.

Negative indexes can not be used.

firstMatch

Source

Match? firstMatch()

Returns the first direct sub-match.

getMatch

Source

@Operator
Match? getMatch(Str label)

Returns the direct sub-match with the given label (or rule name) at the given index.

Use negative index to access from the end of the list.

getMatchAt

Source

@Operator
Match? getMatchAt(Int index)

Returns the direct sub-match at the given index.

lineNum

Source

Int lineNum()

Returns the line number of this match in the input string. Number is one-based.

location

Source

Int[] location()

Returns the [x,y] character location of this match in the input string. Coordinates are one-based.

matched

Source

Str matched()

Returns the matched string.

matchedRange

Source

Range matchedRange()

Returns the matched range; where this match lies within the input string.

matches

Source

Match[] matches(Str? label := null)

Returns all direct sub-matches, optionally with the given label / name.

name

Source

Str? name()

Returns the associated rule label (or name if label is null).

parent

Source

Match? parent()

Returns the parent Match in the tree, or null if this is the root.

rule

Source

Rule rule()

Returns the rule associated with this match.

snippet

Source

Str snippet(Str? msg := null, Int? padding := null)

Returns a snippet of source code, centred on this match.