Arithmetics¶
Source: examples/arithmetics
arithmetics is the smallest example that still shows the full Pegium loop:
parser, language services, validation, formatting, CLI, LSP server, and VS
Code client.
What it shows¶
- a parser for
.calc - a small evaluator
- a formatter
- a stdio LSP server
- a VS Code client
Useful entry points¶
- CLI:
./build/examples/arithmetics/pegium-example-arithmetics-cli - LSP:
./build/examples/arithmetics/pegium-example-arithmetics-lsp
What to read first¶
If you want to understand the example quickly, start with:
examples/arithmetics/src/ArithmeticsModule.cppfor service wiringexamples/arithmetics/src/Language.cppfor the grammar and AST shapingexamples/arithmetics/src/validation/ArithmeticsValidator.cppfor semantic checksexamples/arithmetics/src/lsp/ArithmeticsFormatter.cppfor formatter rules
Why start here¶
This is the smallest example that still exercises parsing, services, validation, formatting, and the editor integration path.
Use this example when¶
- your language is expression-heavy
- you need precedence and associativity
- you want to study
Infixrules - you want the smallest full formatter example