domain specific languages in eclipse with xtext (zeus, ugent)
TRANSCRIPT
Domain Specific Languages in Eclipse with Xtext
redefine.digital.design: Helping you deal with complexity in VHDL and Verilog.
Dr. Ir. Hendrik Eeckhaut
About
CTO at Sigasi @heeckhau
Sigasi Studio: Eclipse based IDE forVHDL and Verilog (digital hardware design)
• Domain Specific Languages (DSL)
• Xtext
• Demo
Overview
Domain specific language
“A domain-specific language (DSL) isa 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
Cold beer
● Optimize energy efficiency● Lots of variants (size, components)● Cooling algorithms
○ Straight forward○ Exceptions and interactions○ Different for variants
Refrigerator control
Refrigerator description
Cooling algorithm
Code Generation
C-code
Documentation
Domain specificsimulator
http://www.voelter.de/data/presentations/RefrigeratorsAndDSLs.pdf
● Understand ?
● Validate ?
● Modify ?
● Develop ?
Why DSLs
DSLs allow to express solutions at theabstraction level of the problem domain.
⇒ Domain experts can understand, validate, modify and develop DSL programs
How ?
Language definition (BNF)
Lexer and Parser
Abstract Syntax Tree
Linking, scoping, types
Validation
Code generator, interpreter
DSL Development Framework
Full DSL infrastructure (parser, linker, …)
Define DSL with a grammar language
⇩
+ Rich editing support for Eclipse, IntelliJ IDEA and web browser
Rich editing
●Syntax coloring
●Type time validation
●Content assist (autocomplete)
●Code formatting
●Find references
●Rename
●Outline
●Hovers
●...
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
To good to be true?
●Xtext contains default implementations for linking, validation, …
●Can be fully customized
●Wired together with Dependency Injection (Google Guice)
Demo
Small DSL to model entities and properties1. datatype String2. 3. entity Blog {4. title: String5. many posts: Post6. }7. 8. entity HasAuthor {9. author: String10. }11. 12. entity Post extends HasAuthor {13. title: String14. content: String15. many comments: Comment16. }17. 18. entity Comment extends HasAuthor {19. content: String20. }
Demo
1. datatype String2. 3. entity Blog {4. title: String5. many posts: Post6. }7. 8. entity HasAuthor {9. author: String10. }11. 12. entity Post extends HasAuthor {13. title: String14. content: String15. many comments: Comment16. }17. 18. entity Comment extends HasAuthor {19. content: String20. }
elements : Type(datatype or entity)
features : Feature
Domainmodel
Demo
1. datatype String2. 3. entity Blog {4. title: String5. many posts: Post6. }7. 8. entity HasAuthor {9. author: String10. }11. 12. entity Post extends HasAuthor {13. title: String14. content: String15. many comments: Comment16. }17. 18. entity Comment extends HasAuthor {19. content: String20. }
Live Demo
Why Xtext
Very mature and complete system
Statically typed AST model
Open Source
Outro
DSLs?
●Very powerful
●Lots of work
Xtext
●Recommended DSL development framework
Sigasi is hiring: www.sigasi.com/careers
Hands on
Download Eclipse IDE for Java and DSL Developershttps://www.eclipse.org/downloads/
Start 15 Minutes tutorial from
https://eclipse.org/Xtext/documentation/102_domainmodelwalkthrough.html