C++20 language engineering toolkit
Bring language engineering to modern C++.
Pegium is an open source toolkit for building textual languages with first-class support for parsing, AST/CST construction, references, validation, formatting, and language-server features.
Why Pegium?¶
-
Semantics First
Shape the semantic model of your language directly through C++ AST types and grammar assignments, while still keeping CST data available for source-aware tooling.
-
Lean By Default
Start from
makeDefaultServices(...), keep the default LSP and workspace behavior where it helps, and override only the parts that are language-specific. -
Parser To Editor
Use one coherent document model for parsing, linking, diagnostics, formatting, completion, rename, references, and other editor-facing features.
-
Examples That Scale
Explore
arithmetics,domainmodel,requirements, andstatemachineas real starting points instead of isolated API snippets.
Start Here¶
-
Start with the high-level picture, then branch into features, showcases, or deeper concepts.
If you want a guided orientation page first, open Choose Your Path.
-
Follow the recommended path from repository build to grammar, AST, references, validation, formatting, and editor services.
-
Use focused guides for common customization tasks such as scoping, validation, caching, multiple languages, and LSP overrides.
-
Use the canonical subsystem pages for grammar, semantic model, services, workspace, and document lifecycle concepts.
-
Inspect complete example languages and choose the best starting point for your own project.
Repository¶
Pegium keeps its documentation and examples in the main repository so the code and the docs stay close to each other: