pub struct Param {
pub semantic: Option<String>,
pub name: String,
pub type_name: String,
pub param_type: ParamType,
}Expand description
Parameter of a rule derivation.
The parameters are used as derivation steps when generating the Abstract Syntax Tree (AST). When generating the AST, they are processed in the order they are defined. They are also used to generate the Parse Tree (PT). The rule’s custom body defines what the Parse Tree looks like.
A parameter consistens of:
- Optional semantic annotation
- Name of the parameter
- Type of the parameter
The type can be:
- Another rule Foo (e.g. param: Foo)
- A token type Bar (e.g. param: token Bar)
- A token type that also requires the content to match (e.g. param token Keyword “if”)
A parameter can also be optional (e.g. param: optional Foo) or a list (e.g. param: Foo+), or both. An optional list can be empty while a required list needs to have at least 1 element.
The generated Parse Tree (PT) will have different object types depending on the parameter type.
Fields§
§semantic: Option<String>Semantic type of the parameter.
name: StringName of the parameter.
type_name: StringType name of the parameter (either rule type of token type)
param_type: ParamTypeInternal type representation of the parameter