SysML Syntax Explorer

The SysML Syntax Explorer is a browser-based tool to visualize how Syside parses SysML v2 code. It displays code as an interactive concrete syntax tree (CST) structure, revealing the underlying hierarchy of declarations, expressions, and other language constructs. Use this tool to accelerate Syside Automator script development to quickly identify any elements of interest and how to parse them.

Privacy

The Syntax Explorer runs entirely in your browser. No code is transmitted to any server, and nothing is logged or stored. Safe for use with proprietary models.

How to Use the Syntax Explorer

Enter or paste SysML v2 code in the Code editor panel. The syntax tree will appear immediately in the Tree panel and update in real-time as you type.

You can click any node in the tree to highlight the corresponding code, or click code in the editor to jump to its location in the tree.

Language Selection

Use the language dropdown to switch between SysML v2 and KerML parsing modes.

Anonymous Nodes

Enable this option to show unnamed syntax nodes in the tree. This is helpful when you need to understand the complete parse structure including implicit elements like punctuation and keywords.

Query Editor

You can open the query editor to write tree-sitter query patterns that match specific syntax elements. Queries use tree-sitter’s S-expression syntax to select nodes by type.

For example, this query highlights all identifiers:

(NAME) @module

Matched elements will be highlighted in the code editor. For more details on query syntax, see the tree-sitter query documentation.

Accessibility

When using queries, use this toggle to switch between color-based and marker-based highlighting for better visual distinction of matched elements.

Open in New Tab

Opens the explorer as a standalone page for full-screen usage.

Note

Your current code and queries will not transfer to the new window.

Practical Examples

Copy the following code snippets into the Code window above to explore the insights described below.

Extracting Model Data

Attribute Declarations
part def Vehicle {
    attribute mass : Real;
    attribute 'max speed' : Real;
}

The tree shows how attributes nest within definitions and how quoted names are tokenized differently from unquoted identifiers.

Expression Parsing
attribute totalCost = baseCost + quantity * unitPrice;

The tree reveals operator precedence: quantity * unitPrice groups first as a subtree before the addition operation.

Feature Chains/Navigation
attribute distance = vehicle.wheel.diameter * 3.14;

The expression vehicle.wheel.diameter creates nested levels in the tree: vehicle contains wheel, which contains diameter. Scripts analyzing these chains must traverse each level separately.

Tracking Dependencies

Import Statements

The tree distinguishes wildcard imports (*) from specific element imports—useful when tracking dependencies.

import ScalarValues::*;
import VehicleLibrary::Vehicle;
Binding Connectors

The bind keyword creates a distinct statement type with separate left/right subtrees—different from assignment expressions despite similar syntax.

bind actualMass = vehicle.mass;

Working with Documentation

Comments vs Documentation
// This is a comment
doc /* This is documentation */
part def Example;

Line comments (//) appear as note nodes in the tree, while block comments inside doc statements parse as documentation body text attached to elements.

Metadata Attachment
#myTool::customMetadata
part def Component {
    doc /* This is a component */
}

The tree shows where metadata annotations attach relative to their target elements and how documentation comments are structured.

Understanding Logic & Constraints

Constraints and Assertions
constraint def MassLimit {
    attribute maxMass: Real;
    assert constraint { mass <= maxMass }
}

When extracting constraint logic, the tree reveals that assert blocks nest the boolean expression several levels deep and not at the constraint definition level.

Collection Syntax
attribute values: Real[0..*] = (1.0, 2.0, 3.0);

Multiplicity bounds and collection literals appear as distinct subtrees in the parsed structure.