Skip to content

Latest commit

 

History

History
34 lines (22 loc) · 758 Bytes

default_actions_for_terminals.md

File metadata and controls

34 lines (22 loc) · 758 Bytes

Default Actions For Terminals

The default action for a regular expression terminal is to convert its internal data type to String. For example, consider the grammar below:

S: A;

terminals

A: /\d+/;

The action of terminal A is to convert A's internal data type Token to type A, which is a String.

pub type A = String;

pub fn a(_ctx: &Ctx, token: Token) -> A {
    token.value.into()
}

Note that token.value is of type Input, which is also defined in the action file:

pub type Input = str;

On the other hand, string terminals have no actions.

➡️ Next: Default Actions For Grammar Rules

📘 Back: Table of contents