Struct Rule
pub struct Rule {
pub origin: String,
pub origin_id: NontermId,
pub expansion: Vec<Symbol>,
pub alias: Option<String>,
pub order: i64,
pub expand1: bool,
pub priority: Option<i32>,
pub keep_all_tokens: bool,
pub empty_indices: Vec<bool>,
pub display_id: DisplayId,
pub shape: RuleShape,
}Expand description
A grammar rule. Lark’s RuleOptions fields are flattened onto the rule
(keep flattened): a rule with multiple BNF expansions would otherwise SHARE
one options object, which is exactly the aliasing that makes Lark’s
priority='invert' negate a multi-expansion rule once per expansion (a net
no-op — see the tp_prio_plus_invert note in the conformance corpus). Owning
the fields by value makes that class of bug unrepresentable.
Flat storage, not a flat parameter list: in-crate construction goes
through Rule::build from a RuleDraft rather than threading the fields
one by one.
The raw keep_all_tokens is retained: AmbiguousExpander needs it
and it is not reconstructible from
RuleShape::to_include.
Fields§
§origin: String§origin_id: NontermIdThe origin nonterminal’s id — a goto_actions COLUMN index (the LHS
nonterminal a reduce gotos on), NOT a rule index. The rules[] index
space is RuleId.
expansion: Vec<Symbol>§alias: Option<String>§order: i64§expand1: bool§priority: Option<i32>Rule priority (rule.3:); None when undeclared. Earley ambiguity
resolution consumes it.
keep_all_tokens: bool§empty_indices: Vec<bool>Lark’s maybe_placeholders encoding: true at logical position i =
“insert a placeholder here at reduce time”.
display_id: DisplayIdIndex into ParseTable::display_names (origin, or alias when present).
shape: RuleShapePrecomputed reduce-time shaping (built by build_rule_shape).