Skip to main content

Module parser

Module parser 

Source
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:

  1. Find the smallest subtree containing the change
  2. Reparse only that subtree
  3. 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§

GreenNode
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
SyntaxError
A syntax error with location and message
TextRange
Re-export rowan types for convenience A range in text, represented as a pair of TextSize.
TextSize
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§

SyntaxKind
All syntax kinds (tokens and nodes) in SysML v2
SysMLLanguage
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§

SyntaxElement
SyntaxNode
Type aliases for convenience
SyntaxToken