The Spoofax Language Workbench Lennart Kats Eelco Visser
Software Engineering implement Problem Software validate
High-level languages reduce problem/solution gap Problem HLL Machine Domain
Domain-Specific Languages Problem DSL HLL Machine Domain DSLs further reduce gap between problem domain and implementation
Example DSL:
paradigm: linguistic abstraction
making languages should be cheap
Compiler Ingredients Syntax definition concrete syntax ★ parser abstract syntax ★ generators Static semantics meta- programming error checking ★ libraries name resolution ★ meta- type analysis ★ programming Model-to-model transformation languages template express constructs in core language ★ engines Code generation translate core language models to implementation ★
Editor Services syntactic editor services semantic editor services • • syntax highlighting error marking • • syntax checking reference resolving • • outline view hover help • • bracket matching, insertion mark occurrences • • automatic indentation content completion • • syntax completion refactoring • • ... ...
Semantic Editor Services } Syntax definition Static semantics Model-to-model transformation Language workbenches Code generation [Fowler ’05] Syntactic Editor Services how can we make these things cheaply?
Language Workbench: integrated environment for language definition
Holy Grail of Software Language Definition Automatically derive efficient, scalable, incremental compiler + usable IDE from high-level, declarative language definition
Stratego SDF Eclipse IMP
Stratego Language Definition by Transformation SDF Eclipse IMP
• <spoofax screenshot: lang def and lang use in Eclipse workspace>
SDF: Declarative Syntax Definition
A syntax definition specifies a transformation from text to trees
Syntax as Transformation
Syntax as Transformation
Syntax as Transformation t r a n s f o r m
Syntax as Transformation t r a n s f o r m
Syntax as Transformation t r a n s f o r m
Semantics = transformation
Error Marking is a Transformation t r a n s f o r m
Error Marking is a Transformation t r a n s f o r m
Error Marking is a Transformation t r a n s f o r m transform
Error Marking is a Transformation t r a n s f o r m transform
Error Marking is a Transformation t r a n s f o r m transform
Outline View is a Transformation transform
Hyperlinking is a Transformation transform
Content Completion is a Transformation transform transform
Code Generation is a Transformation t r a n s f o r m
Need for single, unified language specification: • Editor services • Model transformations • Code generation
Stratego: Rewriting Language
Rewrite rules Strategies
Error Marking with Rewrite Rules
Error Marking with Rewrite Rules
Error Marking with Rewrite Rules t Origin tracking r a n s f o r m transform
Analysis with Rewrite Rules
Code Generation with Rewrite Rules
Conclusion • Co-evolution of language and IDE • Pure and declarative syntax definition • Language definition by transformation • www.spoofax.org: papers, tour, download
Recommend
More recommend