A domain-specific language for e-commerce promotion management, built with Eclipse Xtext.
- Eclipse IDE for Java and DSL Developers (2024-12 or later)
- Xtext 2.41.0 (included in the Eclipse DSL package)
- Java 21
- Clone the repository.
- In Eclipse: File > Import > General > Existing Projects into Workspace.
- Select the repository root. Eclipse should detect these projects:
uk.ac.kcl.inf.promodsl(language runtime)uk.ac.kcl.inf.promodsl.ide(IDE services)uk.ac.kcl.inf.promodsl.ui(Eclipse editor integration)uk.ac.kcl.inf.promodsl.tests(test suite)
- Import all four. Wait for the workspace to build.
- If there are build errors, right-click
uk.ac.kcl.inf.promodsl> Run As > MWE2 Workflow onGeneratePromoDSL.mwe2to regenerate the language infrastructure.
- Right-click
uk.ac.kcl.inf.promodsl> Run As > Eclipse Application. A second Eclipse instance opens. - In the new instance: File > New > Project > General > Project. Name it
promo-demo. - Copy the files from
examples/into the new project. - Open
full-store.promo. You should see syntax highlighting and code completion (Ctrl+Space). - Open
conflict-scenario.promo. You should see validation markers (errors, warnings, info) in the editor. Hover over them to read the messages. Click the lightbulb icon to apply quick-fixes.
The interpreter evaluates a .promo file against simulated order scenarios.
- In the main Eclipse instance, open
PromoDSLRunner.javainuk.ac.kcl.inf.promodsl/src/.../interpreter/. - Run As > Java Application.
- By default it loads
examples/full-store.promoand runs four order scenarios, printing a breakdown of which promotions applied, which were skipped, and why.
To run against a different file, pass the path as a command-line argument in the Run Configuration.
The code generator produces a standalone PromotionEngine.java from any .promo file.
- In the runtime Eclipse instance, open any
.promofile in thepromo-demoproject. - On save, the generator runs automatically. Check the
src-gen/folder forpromodsl/generated/PromotionEngine.java. - The generated file has no runtime dependencies and includes a
mainmethod you can run directly.
- In the main Eclipse instance, right-click
uk.ac.kcl.inf.promodsl.tests> Run As > JUnit Plug-in Test. - Four test suites should pass: parsing, validation, interpreter, and code generator.
uk.ac.kcl.inf.promodsl/
src/.../PromoDSL.xtext Grammar definition
src/.../validation/ Validator (well-formedness + semantic checks)
src/.../interpreter/ Interpreter + conflict resolver + runner
src/.../generator/ M2T code generator (Xtend)
src/.../scoping/ Custom cross-reference scoping
src/.../util/ Shared utilities (model traversal, date parsing)
examples/ Example .promo files
model/generated/PromoDSL.ecore Generated metamodel
uk.ac.kcl.inf.promodsl.ui/
src/.../quickfix/ Quick-fix provider
uk.ac.kcl.inf.promodsl.tests/
src/.../tests/ JUnit 5 test suites
category Electronics
segment StudentDiscount
campaign "Summer Sale 2026"
from 2026-06-01 until 2026-08-31
{
promotion "Student Electronics Deal"
priority 5
applies-when customer.segment is StudentDiscount
and product.category is Electronics
and order.total > 100
discount 15%
max-per-customer 2
channels website, app
stackable
}