This example is the smallest end-to-end Pegium language in the repository.
It is a good starting point when you want to understand the full path from grammar to CLI and language server without first dealing with a large semantic model.
- a parser for the
.calclanguage - an evaluator for arithmetic expressions
- validation and formatting
- a stdio LSP server for
arithmetics - a VS Code client for interactive testing
- your language is expression-heavy
- you need precedence and associativity
- you want to study
Infixrules - you want the most compact full-stack Pegium example
From the repository root:
cmake -S . -B build
cmake --build build./build/examples/arithmetics/pegium-example-arithmetics-cli \
eval examples/arithmetics/example/example.calc./build/examples/arithmetics/pegium-example-arithmetics-lspcmake -S . -B build
cmake --build buildcd examples/arithmetics
npm install
npm run compile- Open the repository root in VS Code.
- Go to
Run and Debug. - Start
Run Arithmetics ExtensionwithF5.
The launch configuration lives in the repository root
.vscode/launch.json and opens an Extension Development Host on
examples/arithmetics/example.
If the server binary is not found automatically, set either:
- the
pegium.arithmetics.serverPathsetting - the
PEGIUM_ARITHMETICS_SERVERenvironment variable