Skip to content

Latest commit

 

History

History
36 lines (24 loc) · 987 Bytes

default_names_for_terminals.md

File metadata and controls

36 lines (24 loc) · 987 Bytes

Default Names For Terminals

Symbols in a grammar will be converted to different data types in the action file. Let's start from terminals.

There are two types of terminals: strings and regular expressions. String terminals will not be converted to any data types and thus cannot be found in the action file. They are just for the parser to find the correct way to parse the input.

On the other hand, regular expression terminals will be converted to type. For example:

S: A;

terminals

A: /\d+/;

Regular expression terminal A is converted to a type of String.

pub type A = String;

There is an fn with the same name as the regular expression terminal but in lower case. This fn is associated with the terminal and will be introduced later.

pub fn a(_ctx: &Ctx, token: Token) -> A

➡️ Next: Default Names For Grammar Rules

📘 Back: Table of contents