Rule

org.parboiled2.Rule
See theRule companion object
sealed class Rule[-I <: HList, +O <: HList] extends RuleX

The general model of a parser rule. It is characterized by consuming a certain number of elements from the value stack (whose types are captured by the HList type parameter I for "Input") and itself pushing a certain number of elements onto the value stack (whose types are captured by the HList type parameter O for "Output").

At runtime there are only two instances of this class which signal whether the rule has matched (or mismatched) at the current point in the input.

Attributes

Companion
object
Graph
Supertypes
trait RuleX
class Object
trait Matchable
class Any
Known subtypes
object Rule.type

Members list

Value members

Concrete methods

def *(implicit l: Lifter[Seq, I, O]): Rule[In, OptionalOut] & Repeated

Postfix shortcut for zeroOrMore.

Postfix shortcut for zeroOrMore.

Attributes

def *(separator: Rule0)(implicit l: Lifter[Seq, I, O]): Rule[In, OptionalOut]

Postfix shortcut for zeroOrMore(...).separatedBy(...).

Postfix shortcut for zeroOrMore(...).separatedBy(...).

Attributes

def +(implicit l: Lifter[Seq, I, O]): Rule[In, StrictOut] & Repeated

Postfix shortcut for oneOrMore.

Postfix shortcut for oneOrMore.

Attributes

def +(separator: Rule0)(implicit l: Lifter[Seq, I, O]): Rule[In, StrictOut]

Postfix shortcut for oneOrMore(...).separatedBy(...).

Postfix shortcut for oneOrMore(...).separatedBy(...).

Attributes

def ?(implicit l: Lifter[Option, I, O]): Rule[In, OptionalOut]

Postfix shortcut for optional.

Postfix shortcut for optional.

Attributes

def named(name: String): Rule.this.type

Attaches the given explicit name to this rule.

Attaches the given explicit name to this rule.

Attributes

def unary_!: Rule0

Creates a "negative syntactic predicate", i.e. a rule that matches only if this rule mismatches and vice versa. The resulting rule doesn't cause the parser to make any progress (i.e. match any input) and also clears out all effects that the underlying rule might have had on the value stack.

Creates a "negative syntactic predicate", i.e. a rule that matches only if this rule mismatches and vice versa. The resulting rule doesn't cause the parser to make any progress (i.e. match any input) and also clears out all effects that the underlying rule might have had on the value stack.

Attributes

def |[I2 <: I, O2 >: O <: HList](that: Rule[I2, O2]): Rule[I2, O2]

Combines this rule with the given other one in a way that the resulting rule matches if this rule matches or the other one matches. If this rule doesn't match the parser is reset and the given alternative tried. This operators therefore implements the "ordered choice' PEG combinator.

Combines this rule with the given other one in a way that the resulting rule matches if this rule matches or the other one matches. If this rule doesn't match the parser is reset and the given alternative tried. This operators therefore implements the "ordered choice' PEG combinator.

Attributes

def ~[I2 <: HList, O2 <: HList](that: Rule[I2, O2])(implicit i: TailSwitch[I2, O, I], o: TailSwitch[O, I2, O2]): Rule[Out, Out]

Concatenates this rule with the given other one. The resulting rule type is computed on a type-level. Here is an illustration (using an abbreviated HList notation): Rule[, A] ~ Rule[, B] = Rule[, A:B] Rule[A:B:C, D:E:F] ~ Rule[F, G:H] = Rule[A:B:C, D:E:G:H] Rule[A, B:C] ~ Rule[D:B:C, E:F] = Rule[D:A, E:F]

Concatenates this rule with the given other one. The resulting rule type is computed on a type-level. Here is an illustration (using an abbreviated HList notation): Rule[, A] ~ Rule[, B] = Rule[, A:B] Rule[A:B:C, D:E:F] ~ Rule[F, G:H] = Rule[A:B:C, D:E:G:H] Rule[A, B:C] ~ Rule[D:B:C, E:F] = Rule[D:A, E:F]

Attributes

def ~!~[I2 <: HList, O2 <: HList](that: Rule[I2, O2])(implicit i: TailSwitch[I2, O, I], o: TailSwitch[O, I2, O2]): Rule[Out, Out]

Same as ~ but with "cut" semantics, meaning that the parser will never backtrack across this boundary. If the rule being concatenated doesn't match a parse error will be triggered immediately.

Same as ~ but with "cut" semantics, meaning that the parser will never backtrack across this boundary. If the rule being concatenated doesn't match a parse error will be triggered immediately.

Attributes