View Source Grammar.Rule (Grammar v0.4.0)
A Rule entity represents a single rule in the grammar.
It has a name, a list of mutually exclusive clauses
and epsilon flag indicating if the rule is mandatory or not.
Summary
Functions
Append a clause to the rule.
Return true is the rule is not mandatory.
Create a new empty rule with a given name and epsilon flag.
Types
@type name() :: atom()
@type t() :: %Grammar.Rule{ clauses: [Grammar.Clause.t()], epsilon?: boolean(), name: name() }
Functions
@spec add_clause(t(), Grammar.Clause.t()) :: t()
Append a clause to the rule.
Clauses must be mutually exclusive, and must added in the order of their priority if ambiguity during token extraction is possible (which must be avoided as much as possible).
Return true is the rule is not mandatory.
If a Rule is optional, and so epsilon is true, it is reduced to nil during the parsing
if not entered.
Create a new empty rule with a given name and epsilon flag.