DomainModel¶
Source: examples/domainmodel
domainmodel is the clearest example of a declaration-oriented DSL in Pegium.
It is a good bridge between the compact arithmetics example and more
workspace-oriented examples.
What it shows¶
- a modeling language for packages, entities, and datatypes
- structured AST nodes
- formatting with block-style layout
- rename and editor support through LSP
Useful entry points¶
- CLI:
./build/examples/domainmodel/pegium-example-domainmodel-cli - LSP:
./build/examples/domainmodel/pegium-example-domainmodel-lsp
What to read first¶
The most useful reading path is usually:
examples/domainmodel/src/DomainModelModule.cppfor service compositionexamples/domainmodel/include/domainmodel/ast.hppfor declarations built onpegium::NamedAstNodeexamples/domainmodel/src/references/QualifiedNameProvider.cppfor qualified-name constructionexamples/domainmodel/src/references/DomainModelScopeComputation.cppfor qualified exports and local symbolsexamples/domainmodel/src/lsp/DomainModelRenameProvider.cppfor rename behaviorexamples/domainmodel/src/lsp/DomainModelFormatter.cppfor block-oriented formatting
Why start here¶
Use this example when your language looks like a modeling DSL rather than an expression language.
Use this example when¶
- the language has declarations, nesting, and blocks
- qualified names matter
- you want a clearer example of references and rename than
arithmetics - you want a formatter centered on keywords and brace blocks