Expand description
Parser: Logos lexer, recursive-descent parser, grammar traits Rowan-based incremental parser for SysML v2
This module provides a lossless, incremental parser using:
- logos for fast lexing
- rowan for the CST (Concrete Syntax Tree)
This is the rust-analyzer approach: we build a lossless CST that preserves all whitespace and comments, then extract an AST layer on top.
§Architecture
Source Text
↓
Lexer (logos) → Tokens with SyntaxKind
↓
Parser → GreenNode tree (immutable, cheap to clone)
↓
SyntaxNode (rowan) → CST with parent pointers
↓
AST layer → Typed wrappers over SyntaxNode
↓
HIR → Semantic model§Incremental Reparsing
When text changes, we:
- Find the smallest subtree containing the change
- Reparse only that subtree
- Reuse unchanged green nodes (they’re immutable and cheap to share)
Re-exports§
pub use ast::*;
Modules§
- ast
- Typed AST wrappers over the untyped rowan CST.
- grammar
- Grammar modules for KerML and SysML parsing
- keywords
- Keyword definitions extracted from KerML and SysML grammars
Structs§
- Green
Node - Re-export rowan types for convenience Internal node in the immutable tree. It has other nodes and tokens as children.
- Lexer
- Lexer wrapping the logos-generated tokenizer
- Parse
- Parse result containing the green tree and any errors
- Syntax
Error - A syntax error with location and message
- Text
Range - Re-export rowan types for convenience
A range in text, represented as a pair of
TextSize. - Text
Size - Re-export rowan types for convenience A measure of text length. Also, equivalently, an index into text.
- Token
- A token with its kind, text, and position
Enums§
- Syntax
Kind - All syntax kinds (tokens and nodes) in SysML v2
- SysML
Language - Language definition for Rowan
Functions§
- kind_
to_ name - Convert a SyntaxKind to a human-readable name for error messages.
- parse_
kerml - Parse KerML source code into a CST
- parse_
sysml - Parse SysML source code into a CST
Type Aliases§
- Syntax
Element - Syntax
Node - Type aliases for convenience
- Syntax
Token