DomainModel¶
Source: examples/domainmodel
domainmodel is the clearest example of a declaration-oriented DSL in Pegium, bridging the compact arithmetics example and the more workspace-oriented ones.
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
Entry points¶
- CLI:
./build/examples/domainmodel/pegium-example-domainmodel-cli generate examples/domainmodel/example/blog.dmodel - LSP:
./build/examples/domainmodel/pegium-example-domainmodel-lsp
What to read first¶
examples/domainmodel/src/domainmodel/core/CoreModule.cppfor service compositionexamples/domainmodel/src/domainmodel/core/ast.hppfor declarations built onpegium::NamedAstNodeexamples/domainmodel/src/domainmodel/core/references/QualifiedNameProvider.cppfor qualified-name constructionexamples/domainmodel/src/domainmodel/core/references/DomainModelScopeComputation.cppfor qualified exports and local symbolsexamples/domainmodel/src/domainmodel/lsp/DomainModelRenameProvider.cppfor rename behaviorexamples/domainmodel/src/domainmodel/lsp/DomainModelFormatter.cppfor block-oriented formatting
Use this example when¶
- your language is a modeling DSL rather than an expression language
- 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