Skip to main content

Module cst

Module cst 

Source
Available on crate feature parser only.
Expand description

The concrete syntax tree (CST) and the parser that produces it.

The parser itself is generated at build time by lelwel from the grammar in src/parser/wright.llw and included here. This module implements the ParserCallbacks trait that the generated code relies on for:

  • Tokenization (delegated to crate::lexer, see lexer.rs in this module).
  • Creating Diagnostics for syntax errors.
  • The semantic predicates (?N) and actions (#N) referenced by the grammar.

The CST is lossless – every token from the source (including whitespace and comments) is in it. It’s mostly useful as an intermediate step to the AST, but is also exposed via SyntaxTree for tooling such as formatters that need every token.

Structs§

Cst
A concrete syntax tree (CST) type.
CstChildren
An iterator for child nodes of a CST node.
CstData
CstIndex64-bit
NodeRef
ParseContext
Context carried through a parse and used by the semantic predicates and actions.
Parser
SyntaxTree
A lossless concrete syntax tree for a Source, as produced by the generated parser.

Enums§

Node
Type of a node in the CST.
Rule

Traits§

ParserCallbacks

Type Aliases§

Span