Grammar and editor tooling reference
This page is the exact map for FCSTM grammar, syntax highlighting, and editor maintenance. For the task workflow, see Grammar and editor tasks. For rationale, see Grammar tooling explanation.
Canonical source and generated files
Area |
Path |
Source or generated |
Notes |
|---|---|---|---|
Parser grammar |
|
source |
Parser rules for FCSTM constructs. |
Lexer grammar |
|
source |
Tokens, keywords, literals, and operators. |
Python parser output |
|
generated |
Regenerated by |
DSL listener |
|
source |
Converts parse events into AST nodes. |
DSL AST nodes |
|
source |
Syntax tree dataclasses and export helpers. |
Model importer |
|
source |
Converts AST nodes into semantic model objects and diagnostics. |
Pygments lexer |
|
source |
Documentation and Python-side syntax highlighting. |
TextMate grammar |
|
source |
Shared TextMate-compatible highlighting grammar. |
Editor validation |
|
source command |
Repository validation for highlighter/editor asset consistency. |
JavaScript frontend |
|
source and generated local assets |
JavaScript parser/runtime assets for editor integrations. |
VSCode extension |
|
source and build output |
VSCode packaging and authoring features. |
LLM grammar guide |
|
source prompt asset |
Update with syntax changes and refresh |
Core maintenance commands
Command |
Purpose |
Typical trigger |
|---|---|---|
|
Download/setup ANTLR support when needed. |
First local grammar-maintenance setup. |
|
Regenerate parser outputs after editing |
Any grammar file change. |
|
Validate syntax highlighting and editor asset consistency. |
Grammar, keyword, operator, Pygments, or TextMate changes. |
|
Build the VSCode extension package. |
VSCode package or extension integration changes. |
|
Remove VSCode extension build artifacts. |
Local cleanup. |
|
Refresh generated checksum sidecars. |
LLM grammar guide content change. |
|
Verify LLM guide packaging and checksum behavior. |
LLM guide or prompt-asset changes. |
Pygments and Sphinx facts
The package registers pyfcstm.highlight.pygments_lexer.FcstmLexer
through the pygments.lexers entry point in setup.py. The canonical alias
is fcstm; fcsm is also accepted by the lexer.
Programmatic load check:
from pygments.lexers import get_lexer_by_name
lexer = get_lexer_by_name("fcstm")
Sphinx also registers the lexer in docs/source/conf.py. User-facing FCSTM
examples should use:
.. code-block:: fcstm
state Root {
state Idle;
[*] -> Idle;
}
TextMate facts
The repository TextMate grammar is editors/fcstm.tmLanguage.json. It is the
source for TextMate-compatible highlighting and is copied into the VSCode
extension’s syntaxes/ area during packaging.
For Sublime Text integration, place the same file under a package directory such
as FCSTM in Preferences -> Browse Packages.
VSCode extension facts
File or directory |
Purpose |
|---|---|
|
Extension manifest, commands, activation, language contribution, and scripts. |
|
Comment, bracket, indentation, and editor language behavior. |
|
Problems-panel diagnostics and inline squiggles. |
|
Document symbols for Outline and breadcrumbs. |
|
IntelliSense for keywords, constants, built-ins, and document-local symbols. |
|
Contextual help for event scopes, pseudo states, lifecycle keywords, and aspect syntax. |
|
Snippets for common variable, state, transition, and lifecycle forms. |
|
Bundled output. |
|
Local |
Local VSIX installation:
code --install-extension editors/vscode/build/fcstm-language-support-0.1.0.vsix
VSCode verification suites
Command |
Focus |
|---|---|
|
Parser integration. |
|
Syntax diagnostics. |
|
Document symbols. |
|
Completion support. |
|
Hover documentation. |
|
Aggregate extension verification, including newer semantic, import, preview, and end-to-end checks. |
Operator ordering facts
Lexer patterns and highlighters should put multi-character operators before single-character operators.
Longer token |
Must precede |
Why |
|---|---|---|
|
|
Exponentiation must not be tokenized as two multiplication tokens. |
|
|
Shift must not split into two less-than tokens. |
|
|
Comparisons must keep their equality suffix. |
|
|
Equality and inequality must not split into assignment or negation tokens. |
|
|
Logical operators must not split into bitwise-looking pieces. |
Keyword update checklist
When syntax changes add a keyword or operator, update these facts together:
ANTLR grammar files under
pyfcstm/dsl/grammar/.Parser outputs via
make antlr_build.Listener and AST handling when parse-tree shape changes.
Model import and validation when semantic meaning changes.
Pygments lexer groups.
TextMate grammar keyword/operator patterns.
Editor validation expectations.
VSCode diagnostics, completions, hovers, and snippets when authoring behavior changes.
DSL guide, examples, and tests when user-facing syntax changes.
LLM grammar guide and checksum when prompt-facing syntax changes.
Do not document generated parser paths as the source of truth. The .g4 files
are the source; generated parser files are outputs.