Skip to main content

syster/parser/
mod.rs

1//! Rowan-based incremental parser for SysML v2
2//!
3//! This module provides a lossless, incremental parser using:
4//! - **logos** for fast lexing
5//! - **rowan** for the CST (Concrete Syntax Tree)
6//!
7//! This is the rust-analyzer approach: we build a lossless CST that preserves
8//! all whitespace and comments, then extract an AST layer on top.
9//!
10//! ## Architecture
11//!
12//! ```text
13//! Source Text
14//!     ↓
15//! Lexer (logos) → Tokens with SyntaxKind
16//!     ↓
17//! Parser → GreenNode tree (immutable, cheap to clone)
18//!     ↓
19//! SyntaxNode (rowan) → CST with parent pointers
20//!     ↓
21//! AST layer → Typed wrappers over SyntaxNode
22//!     ↓
23//! HIR → Semantic model
24//! ```
25//!
26//! ## Incremental Reparsing
27//!
28//! When text changes, we:
29//! 1. Find the smallest subtree containing the change
30//! 2. Reparse only that subtree
31//! 3. Reuse unchanged green nodes (they're immutable and cheap to share)
32
33#[allow(clippy::module_inception)]
34mod parser;
35
36pub mod ast;
37pub mod grammar;
38pub mod keywords;
39mod lexer;
40mod syntax_kind;
41
42pub use ast::*;
43pub use lexer::{Lexer, Token};
44pub use parser::{Parse, SyntaxError, kind_to_name, parse_kerml, parse_sysml};
45pub use syntax_kind::{SyntaxElement, SyntaxKind, SyntaxNode, SyntaxToken, SysMLLanguage};
46
47/// Re-export rowan types for convenience
48pub use rowan::{GreenNode, TextRange, TextSize};