Pegium Mental Model¶
A quick high-level model of how Pegium fits together, so the subsystem pages make sense.
The five ideas to keep in mind¶
- The grammar is ordinary C++ code.
- The AST is your semantic model.
- References are resolved after parsing, not during parsing.
- Services assemble the language behavior.
- The same document model powers parsing, diagnostics, and editor features.
How to translate your intuition¶
If you come from other language tooling frameworks:
- The parser class is the home of the grammar.
- Your AST structs are the language model you validate and traverse.
- Scoping and linking turn names into targets.
- The service container gives the language its parser, validator, formatter, and editor behavior.
The biggest shift: grammar and language services are ordinary C++ code. You get stronger type coupling with the AST, but less of the declarative grammar-file feel.
What stays similar¶
The workflow is familiar:
- Define the grammar.
- Shape the AST.
- Compute scopes and link references.
- Validate semantics.
- Add formatting and editor features.
Related pages¶
- Build a Language End-to-End
- Grammar Essentials
- References and Scoping
- Validation
- LSP Services
- Reference — precise service and document-model terminology.