Skip to content

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.

C++20 PEG parser DSL LSP

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, and statemachine as real starting points instead of isolated API snippets.

Start Here

  • Introduction

    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.

  • Learn

    Follow the recommended path from repository build to grammar, AST, references, validation, formatting, and editor services.

  • Recipes

    Use focused guides for common customization tasks such as scoping, validation, caching, multiple languages, and LSP overrides.

  • Reference

    Use the canonical subsystem pages for grammar, semantic model, services, workspace, and document lifecycle concepts.

  • Examples

    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: