Domain specific languages in eclipse with Xtext (Zeus, UGent)
1. Domain Specific Languages
in Eclipse with Xtext
redefine.digital.design: Helping you deal with complexity in VHDL and Verilog.
Dr. Ir. Hendrik Eeckhaut
2. About
CTO at Sigasi @heeckhau
Sigasi Studio: Eclipse based IDE for
VHDL and Verilog (digital hardware design)
4. Domain specific language
“A domain-specific language (DSL) is
a computer language
specialized to a particular application domain”
Examples:
●Regular expressions: ^com.sigasi.*$
●SQL: SELECT * FROM table_name
https://en.wikipedia.org/wiki/Domain-specific_language
5. Cold beer
● Optimize energy efficiency
● Lots of variants (size, components)
● Cooling algorithms
○ Straight forward
○ Exceptions and interactions
○ Different for variants
7. Why DSLs
DSLs allow to express solutions at the
abstraction level of the problem domain.
⇒ Domain experts can understand, validate, modify
and develop DSL programs
8. How ?
Language definition (BNF)
Lexer and Parser
Abstract Syntax Tree
Linking, scoping, types
Validation
Code generator, interpreter
9. DSL Development Framework
Full DSL infrastructure (parser, linker, …)
Define DSL with a grammar language
⇩
+ Rich editing support for Eclipse, IntelliJ
IDEA and web browser
11. How
Language definition (BNF)
Lexer and Parser
Abstract Syntax Tree
Linking, scoping, types
Validation
Code generator, interpreter
→ Xtext grammar
→ ANTLR
→ Eclipse EMF
(partially generated)
Java
12. To good to be true?
●Xtext contains default implementations for linking,
validation, …
●Can be fully customized
●Wired together with Dependency Injection
(Google Guice)
13. Demo
Small DSL to model entities and properties
1. datatype String
2.
3. entity Blog {
4. title: String
5. many posts: Post
6. }
7.
8. entity HasAuthor {
9. author: String
10. }
11.
12. entity Post extends HasAuthor {
13. title: String
14. content: String
15. many comments: Comment
16. }
17.
18. entity Comment extends HasAuthor {
19. content: String
20. }
14. Demo
1. datatype String
2.
3. entity Blog {
4. title: String
5. many posts: Post
6. }
7.
8. entity HasAuthor {
9. author: String
10. }
11.
12. entity Post extends HasAuthor {
13. title: String
14. content: String
15. many comments: Comment
16. }
17.
18. entity Comment extends HasAuthor {
19. content: String
20. }
elements : Type
(datatype or entity)
features : Feature
Domainmodel
19. Hands on
Download Eclipse IDE for Java and DSL Developers
https://www.eclipse.org/downloads/
Start 15 Minutes tutorial from
https://eclipse.org/Xtext/documentation/102_domainmodelwalkthrough.html