Rule

alpaca.Rule
trait Rule[R]

Represents a grammar rule in the parser.

A rule defines how a non-terminal symbol can be parsed by specifying one or more productions. Each production maps a pattern of symbols to a result value.

Rules are created using the rule function and can be used in pattern matching within parser productions.

Type parameters

R

the type of value produced when this rule is matched

Attributes

Experimental
true
Source
parser.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

inline def List: PartialFunction[Any, List[R]]

Pattern matching extractor for lists of this rule.

Pattern matching extractor for lists of this rule.

This is compile-time only and should only be used in parser rule definitions.

Attributes

Returns

a partial function that extracts a list of results

Source
parser.scala
inline def Option: PartialFunction[Any, Option[R]]

Pattern matching extractor for optional occurrences of this rule.

Pattern matching extractor for optional occurrences of this rule.

This is compile-time only and should only be used in parser rule definitions.

Attributes

Returns

a partial function that extracts an optional result

Source
parser.scala
inline def unapply(x: Any): Option[R]

Pattern matching extractor for single occurrences of this rule.

Pattern matching extractor for single occurrences of this rule.

This is compile-time only and should only be used in parser rule definitions.

Value parameters

x

the value to match

Attributes

Returns

Some(result) if the match succeeds

Source
parser.scala