classafPegger::Match
sys::Obj afPegger::Match
@
Js
Represents a PEG match result.
- contains
Returns
true
if a there's a direct sub-match with the given rule label or name.- data
Storage for user data - use when investigating match results.
- debugStr
Str debugStr()
Returns the matched tree as a string.
- dump
This dump(OutStream out := Env.cur().out())
Dumps the matched tree to std-out. Useful for debugging.
- findMatch
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
Match? firstMatch()
Returns the first direct sub-match.
- getMatch
@
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
@
Operator
Match? getMatchAt(Int index)Returns the direct sub-match at the given index.
- lineNum
Int lineNum()
Returns the line number of this match in the input string. Number is one-based.
- location
Int[] location()
Returns the
[x,y]
character location of this match in the input string. Coordinates are one-based.- matched
Str matched()
Returns the matched string.
- matchedRange
Range matchedRange()
Returns the matched range; where this match lies within the input string.
- matches
Match[] matches(Str? label := null)
Returns all direct sub-matches, optionally with the given label / name.
- name
Str? name()
Returns the associated rule
label
(orname
iflabel
isnull
).- parent
Match? parent()
Returns the parent Match in the tree, or
null
if this is the root.- rule
Rule rule()
Returns the rule associated with this match.
- snippet
Str snippet(Str? msg := null, Int? padding := null)
Returns a snippet of source code, centred on this match.