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 your language's semantic model directly through C++ AST types and grammar assignments, with CST data still available for source-aware tooling.

  • Lean by default

    Start from makeDefaultServices(...), keep the default LSP and workspace behavior, and override only the language-specific parts.

  • Parser to editor

    Use one document model for parsing, linking, diagnostics, formatting, completion, rename, references, and other editor features.

  • Examples that scale

    Use arithmetics, domainmodel, requirements, and statemachine as real starting points, not isolated API snippets.

Start here

  • Introduction

    Get the high-level picture, then branch into features, showcases, or deeper concepts. Want to jump straight in? Build a language end-to-end in the walkthrough.

  • Learn

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

  • Recipes

    Focused guides for common customization tasks: scoping, validation, caching, multiple languages, and LSP overrides.

  • Reference

    Canonical subsystem pages for grammar, semantic model, services, workspace, and document lifecycle concepts.

  • Examples

    Browse complete example languages and pick the best starting point for your project.

Documentation and examples live in the main repository, so the code and docs stay close together.