abstract classafPegger::Rule
sys::Obj afPegger::Rule
@
Js
(Advanced) Models a PEG Rule.
Rules are commonly created by using methods from the Rules mixin, but may be parsed from string patterns.
Rule may sub-classed to create your own custom rules.
- debug
virtual Bool debug := true
Disable debugging of this rule if it gets too noisy.
- debugOff
This debugOff()
A helpful builder method for turning debug off.
- definition
Str definition()
Returns the PEG definition for this rule. Example:
alphaNum <- [a-zA-Z0-9]
- excludeFromResults
This excludeFromResults()
A helpful builder method for removing this rule from tree results.
- expression
abstract Str expression()
Returns the PEG expression for this rule. Example:
[a-zA-Z0-9]
- label
virtual Str? label
A label for this rule. Only rules with labels appear in the output tree.
Should be legal Fantom identifier (think variable names!).
- match
Matches this rule against the given string.
See Peg.match
- name
virtual Str? name
The name of this rule. Only rules with names appear in debug output.
Should be legal Fantom identifier (think variable names!).
- parseRule
static new parseRule(Str pattern)
- useInResult
virtual Bool useInResult := true
Not all rules are useful in the parsed AST.
- withLabel
A helpful builder method for setting the label. Only rules with labels appear in the output tree.
- withName
A helpful builder method for setting the name.
Only rules with names appear in debug output.