Language Engineering as a Toy Language โ the name is Small D. Integrated with the Eclipse Debug UI ๐, it provides a simple interpreter and debugger.
org.xtext.labs.mydsl.interpreteris fully developed and designed based on parsing results. Itโs not a built-in feature of the Xtend framework.- The interpreter is integrated with the Eclipse Debug UI โ this is an independent module, not relying on Xtend.
- Code editor functionalities are provided and fixed by the Xtend framework.
- Minimap view and deployment are implemented via Eclipse plugin development.
- ANTLR parses the language definition file at
org.xtext.labs.mydsl/src/org/xtext/labs/Mydsl.xtext. Once parsing is complete and the AST is generated, it becomes the foundation for all language customization and engineering.
Small D is a toy language for exploring Language Engineering.
โDโ stands for DSL (Domain-Specific Language). Unlike general-purpose languages like C or Java, DSLs are tailored for specific tasks or domains.
Normally, implementing a new language doesnโt make sense for time- or budget-constrained projects. But sometimes, it's necessary. Unfortunately, simple and practical references are hard to find, and most DSLs are proprietary, making examples rare.
Even finding debugger documentation often leads to low-level gdb or obscure references โ not practical for newcomers. Thatโs why I created a small language with essential IDE features for learning purposes.
I hope it helps you, too. ๐
- What: Lexer ๐ช โ Parser ๐ โ Interpreter ๐ง โ Debuggable Interpreter ๐ โ Eclipse Debug UI ๐๏ธ
- Intermediate Products: Token (lexer) โ AST (parser) โ Call Stack & Symbol Table (interpreter)
- How: Using Xtext Framework ๐ ๏ธ + Custom Implementations ๐ก
Features:
- Error Checking
- Semantic/Syntax Coloring
- Outline View
- Hover Tooltips
- Auto-completion (Proposal)
- Scoping, Cross-referencing, Labeling
- Minimap View
- Formatting, ๐ ๏ธ Quick Fix
- Folding, ๐ Go-To Declaration
๐งฑ Xtext documentation is sparse, sometimes outdated, and the community is small โ but it's still better than nothing.
- Features a ๐งฎ call stack, ๐งพ symbol table, and ๐งฌ AST
- Interpreter can suspend โธ๏ธ and resume
โถ๏ธ based on commands
- Communication with Eclipse Debug UI:
- Request Socket <=> Response (data)
- Event Socket
- Use the Eclipse Product export wizard ๐งโโ๏ธ
- Project:
org.xtext.labs.mydsl.product - File:
DSLDeveloper.product
๐ ๏ธ For installers:
Use Inno Setup โ free and easy ๐ธ
- DSL code can be converted to Java and C# (though not perfectly)
- In C#, all function parameters are converted using
ref(demonstrates call-by-reference) ๐
๐ก Pascal is a well-known language that supports call-by-reference.
Sample code can be found in org.xtext.labs.mydsl.product/src
num,string,bool- Multi-dimensional arrays
if ~ else(noelse if)whileloop only- Function definition:
def function_name() {} launch_mainis the entry point- Scope resolution: local โ global fallback
- No object-oriented features
-
Not supporting Direct function calls in expressions
โ
printstr(numtostr(b))
โa = numtostr(b) printstr(a)
-
Grammar supports multiple operations, but interpreter doesn't yet (lazy dev ๐ ) โ You can define operator precedence manually if needed
printstr(varStr)๐จ๏ธstrjoin(var1, var2)๐varArr = strsplit(var1, "delimiter")varStr = numtostr(varNum)getargs(index)
- Import the project into Eclipse
- Export
org.xtext.labs.mydsl.interpreteras a Runnable JAR - Copy the JAR to your path
- Open
DSLDeveloper.product - Use Eclipse Product Export Wizard (in Overview tab)
- Create a new DSL file from MyDsl project
- Export
debugDSL.jarfromorg.xtext.labs.mydsl.interpreter - Copy to:
D:\DSLDeveloper\debug\debugDSL.jar(example path)
Reference: Robert Wlochโs Blog
1. In the Plug-ins tab change the Launch with select box to plug-ins select below only and uncheck the Target Platform subtree and check the two options below the plug-ins list. In the search field above the plug-ins list enter equinox. and check the equinox.ds plug-in: In the filtered list also check the equinox.util plug-in: Now enter appl in the search field and check the ui.ide.application plug-in:
2. Switch to the Configuration tab and check Clear the configuration area before launching. This ensures that runtime Eclipse doesn't cache plug-in configuration which avoids occational pitfalls.
3. The last change needs to be done in the Common tab. Switch the radio choice to Shared file and enter the Project Explorer path to the product plug-in: /de.rowlo.testgenerator.testdsl.product. This will tell Eclipse to save that run configuration in a launcher file in the specified location:
4. Finally switch back to the Plug-ins tab, clear the search filter and check the checkbox Validate plug-ins automatically prior to launching. Then click several times on Add Required Plug-ins right of the plug-ins list. You can stop clicking when the number of selected plug-ins does not change no more. To check if nothing's missing click on Validate Plug-ins. Eclipse should tell you that no problems were detected. Click on Apply and Close the dialog now.
-
Xtext
-
Language Engineering
-
Eclipse Debugger
-
Deploying as Product
- Main function arguments set via Launch Configuration
- Use DSL Editor (not Xtext Editor) for debugging
- Dev environment: Xtext 2.12.0, Java SE 1.8, Eclipse Neon.3
- Minimap View: https://github.com/apauzies/eclipse-minimap-view
Workaround: switch view or reload it. Details
๐ Many thanks to StackOverflow!
Ports used:
29777,29888
If port error occurs:
cmd> netstat -ona | findstr 0.0:29777
TCP 0.0.0.0:29777 0.0.0.0:0 LISTENING 3116
cmd> taskkill /F /PID 3116๐ PID 3116 will be terminated
ยฉ 2017 kimtth

