Recall that each production of a grammar rule has a corresponding fn
in the action file.
The fn
describes the action that will be taken when a substring of the input is parsed according to the production.
Let us look at an example.
S: A | B;
terminals
A: 'a';
B: 'b';
The fn
s of production A
and B
are:
pub fn s_a(_ctx: &Ctx) -> S {
S::A
}
pub fn s_b(_ctx: &Ctx) -> S {
S::B
}
These fn
s are generated by rcomp
automatically and thus perform the default action, which returns the corresponding variant of the enum
.
pub enum S {
A,
B,
}
➡️ Next: Changing Actions For Terminals
📘 Back: Table of contents