Syster Base
Core library for SysML v2 and KerML parsing, AST, and semantic analysis.
Features
- Parser: Pest-based grammar for SysML v2 and KerML
- AST: Complete abstract syntax tree types
- Incremental Semantic Analysis: Salsa-powered query system with automatic memoization
- Name Resolution: Scope-aware resolver with import handling
- Standard Library: SysML v2 standard library files
Architecture
Syster Base uses a query-based incremental computation model powered by Salsa. This means:
- Automatic memoization — Query results are cached; re-running a query with the same inputs returns instantly
- Automatic invalidation — When an input changes, only dependent queries recompute
- Parallel-safe — Salsa's design enables safe concurrent query execution
Query Layers
file_text(file) ← INPUT: raw source text
│
▼
parse_file(file) ← Parse into AST (memoized per-file)
│
▼
file_symbols(file) ← Extract HIR symbols (memoized per-file)
│
▼
SymbolIndex ← Workspace-wide symbol index
│
▼
Resolver::resolve(name) ← Name resolution with imports
│
▼
file_diagnostics(file) ← Semantic errors
Key Types
| Type | Size | Purpose |
|---|---|---|
FileId |
4 bytes | Interned file identifier (O(1) comparison) |
Name |
4 bytes | Interned string identifier |
DefId |
8 bytes | Globally unique definition ID |
HirSymbol |
— | Symbol extracted from AST |
RootDatabase |
— | Salsa database holding all queries |
Usage
use ;
use FileId;
// Create the Salsa database
let db = new;
// Set file content (input query)
let file_id = new;
let file_text = new;
// Parse (memoized - subsequent calls are instant)
let parse_result = parse_file;
assert!;
// Extract symbols (also memoized)
if let Some = parse_result.get_ast
Modules
base— Foundation types:FileId,Name,Interner,TextRangesyntax— Pest grammars and AST types for KerML/SysMLhir— High-level IR with Salsa queries and symbol extractionide— IDE features: completion, goto, hover, referencesproject— File loading utilities
Performance
The Salsa-based architecture provides significant performance benefits:
- Incremental parsing: Only changed files are re-parsed
- Memoized queries: Symbol extraction, resolution cached automatically
- O(1) comparisons: Interned
FileIdandNameenable constant-time equality - Reduced allocations: String interning shares storage across the codebase
License
MIT
Development
DevContainer Setup (Recommended)
This project includes a DevContainer configuration for a consistent development environment.
Using VS Code:
- Install the Dev Containers extension
- Open this repository in VS Code
- Click "Reopen in Container" when prompted (or use Command Palette: "Dev Containers: Reopen in Container")
What's included:
- Rust 1.85+ with 2024 edition
- rust-analyzer, clippy
- GitHub CLI
- All VS Code extensions pre-configured
Manual Setup
If not using DevContainer:
# Install Rust
|
# Build the project
# Run tests
# Run clippy (required before commit)