modelscript/languages/sysml2 at main · modelscript/modelscript · GitHub
Skip to content

Latest commit

 

History

History

sysml2

Folders and files

README.md

بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ
In the name of Allah, the Compassionate, the Merciful

@modelscript/sysml2

Systems Modeling Language v2 (SysML v2) and Kernel Modeling Language (KerML) compiler, AST querying, formal verification, and cross-domain transformation engine for ModelScript.


Core Capabilities

  • Native WebAssembly GLR Incremental Parser: Generated by @modelscript/dsl (buildParser), compiling directly into high-throughput WASM (parser.wasm) for microsecond parsing and incremental syntax tree recovery.
  • KerML & SysML v2 Standard Library: Embedded snapshots of the KerML and SysML v2 standard libraries for full symbol resolution, type hierarchy deduction, and dimensional quantities.
  • Systems Architecture & Decomposition: Full query support for part definitions, item definitions, ports, connection definitions, allocations, and parametric constraints.
  • Behavioral Modeling & Formal Verification: State machine traversal, activity flow analysis, and SMT / reasoner bridges (smt-bridge.ts, reasoner-bridge.ts) for constraint checking and multiplicity verification.
  • Bidirectional Polyglot TGG Rules: AOT-compiled Triple Graph Grammar rules for bidirectional co-evolution across domains:
    • SysML v2 ↔ Modelica: Map part definitions to Modelica components and attributes to physics parameters (SysML2ToModelica).
    • SysML v2 ↔ OWL 2: Map taxonomies and concepts to ontology subclasses, individuals, and object properties (SysML2ToOWL2SubClassOf, SysML2ToOWL2ObjectProperty, etc.).
    • SysML v2 ↔ STEP CAD: Map physical parts to CAD geometry, dimensional measures, and spatial coordinate placements (SysML2ToStepProduct, SysML2ToStepMeasure, SysML2ToStepPlacement).
  • Visual Diagram Synthesis: Automatic layout generation for block definition diagrams (BDD), internal block diagrams (IBD), and state transition charts.

Scripts

Command Description
npm run build Build WASM parser (via build.js) and compile TypeScript
npm run build:parser Force-rebuild the WebAssembly GLR parser and generated bindings
npm test Run unit, stdlib, and reasoner test suites with CTRF reporter
npm run lint Run ESLint across src/ and transformers/
npm run clean Remove compiled build artifacts and dist/

Programmatic Usage

import { createWasmParser } from "@modelscript/sysml2/parser";
import { sysml2Language } from "@modelscript/sysml2/language";

// 1. Initialize WASM GLR parser
const wasmPath = require.resolve("@modelscript/sysml2/parser.wasm");
const { parser } = await createWasmParser(wasmPath);

// 2. Parse SysML v2 source
const tree = parser.parse(sourceText);

// 3. Inspect polyglot TGG rules for cross-domain compilation
const tggRules = sysml2Language.polyglot?.rules;