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 patterns.

Rule is not intended to be created or subclassed by the user.

action

Source

virtual |Str? action

Action to be performed upon successful completion of this rule.

debug

Source

virtual Bool debug := true

Disable debugging of this rule if it gets to noisy.

definition

Source

Str definition()

Returns the PEG definition for this rule. Example:

alphaNum <- [a-zA-Z0-9]
expression

Source

abstract Str expression()

Returns the PEG expression for this rule. Example:

[a-zA-Z0-9]
label

Source

virtual Str? label

A label for this rule.

match

Source

Match? match(Str str)

Matches this rule against the given string.

See Peg.match

name

Source

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

Source

static new parseRule(Str pattern)

Creates a rule by parsing the given pattern:

Rule.fromPattern("[abc] / [xyz]")

See Peg.parseRule

useInResult

Source

virtual Bool useInResult := true

Not all rules are useful in the parsed AST.

withAction

Source

This withAction(|Str? action)

A helpful builder method for setting the action.

withName

Source

This withName(Str name)

A helpful builder method for setting the name.