Embedding Languages
    without Breaking Tools
Lukas Renggli, Tudor Gîrba, Oscar Nierstrasz




              CHOOSE
     ...
Marco Zanoli, cc-by-sa, 2.5, www.wikipedia.de, 2006
Marco Zanoli, cc-by-sa, 2.5, www.wikipedia.de, 2006
Marco Zanoli, cc-by-sa, 2.5, www.wikipedia.de, 2006
§
§
    §

            Marco Zanoli, cc-by-sa, 2.5, www.wikipedia.de, 2006
Language Engineering
Multiple Context
Dependent Languages
Homogeneous
Data Abstraction
Homogeneous
Tool Integration
Existing
Host Language
Context Specific Languages
with Homogeneous Tool Integration
x=1        x=2

y=1   Package Name   (2, 1)



y=2      (1, 2)      (2, 2)
aBuilder row grow.
aBuilder row fill.

aBuilder column grow.
aBuilder column fill.

aBuilder x: 1 y: 1 add: (LabelShape new
...
row = grow.
row = fill.

column = grow.
column = fill.

(1 , 1) = label
	    	    text: [ :each | each name ];
	    	    bor...
AST Transformation
➊ Pidgin
syntax ‧ vocabulary ‧ semantics
row = grow.
row = fill.

column = grow.
column = fill.

(1 , 1) = label
	    	    text: [ :each | each name ];
	    	    bor...
shape {
	   cols: #grow, #fill;
	   rows: #grow, #fill;
}
label {
	   position: 1 , 1;
	   text: [ :each | each name ];
	   ...
Custom Parser
AST Transformation
➋ Creole
syntax ‧ vocabulary ‧ semantics
shape {
	   cols: #grow, #fill;
	   rows: #grow, #fill;
}
label {
	   position: 1 , 1;
	   text: [ :each | each name ];
	   ...
➌ Argot
syntax ‧ vocabulary ‧ semantics
Transactional Memory

Object Relationships
How does
Helvetia work?
Rules




         <parse>                   <transform>              <attribute>                <bytecode>




Source    ...
Rules




         <parse>                   <transform>              <attribute>                <bytecode>




Source    ...
Rules




         <parse>                   <transform>              <attribute>                <bytecode>




Source    ...
...        <complete>               <highlight>        ...




                                                  Rules



...
...        <complete>               <highlight>        ...




         Creole path
                                      ...
Rule Types

‣ Conditional Rule
  Reflection
‣ Source Rule
  Parser, Regex
‣ AST Rule
  Tree Matcher
Rule Actions



‣ Transformations
‣ Code blocks
‣ Call other rules
<complete>               <highlight>        ...




                                                  Rules




         <...
IV + VII = XI
Assignments and Swapping   Positional Arguments

Automaton                  Quasiquoting and Unquoting

Asynchronous Calls...
Existing Host Language
Multiple Context
Dependent Languages
Homogeneous
Data Abstraction
Homogeneous
Tool Integration
http://scg.unibe.ch/research/helvetia
Rules
Marco Zanoli, cc-by-sa, 2.5, www.wikipedia.de, 2006
Marco Zanoli, cc-by-sa, 2.5, www.wikipedia.de, 2006
Language
                                               *
                                                               C...
http://scg.unibe.ch/research/helvetia
Embedding Languages Without Breaking Tools
Upcoming SlideShare
Loading in...5
×

Embedding Languages Without Breaking Tools

4,650

Published on

Domain-specific languages (DSLs) are increasingly used as embedded languages within general-purpose host languages. DSLs provide a compact, dedicated syntax for specifying parts of an application related to specialized domains. Unfortunately, such language extensions typically do not integrate well with the development tools of the host language. Editors, compilers and debuggers are either unaware of the extensions, or must be adapted at a non-trivial cost. We present a novel approach to embed DSLs into an existing host language by leveraging the underlying representation of the host language used by these tools. Helvetia is an extensible system that intercepts the compilation pipeline of the Smalltalk host language to seamlessly integrate language extensions. We validate our approach by case studies that demonstrate three fundamentally different ways to extend or adapt the host language syntax and semantics.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
4,650
On Slideshare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
13
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Embedding Languages Without Breaking Tools

  1. 1. Embedding Languages without Breaking Tools Lukas Renggli, Tudor Gîrba, Oscar Nierstrasz CHOOSE Swiss Group for Object-Oriented Systems and Environments
  2. 2. Marco Zanoli, cc-by-sa, 2.5, www.wikipedia.de, 2006
  3. 3. Marco Zanoli, cc-by-sa, 2.5, www.wikipedia.de, 2006
  4. 4. Marco Zanoli, cc-by-sa, 2.5, www.wikipedia.de, 2006
  5. 5. § § § Marco Zanoli, cc-by-sa, 2.5, www.wikipedia.de, 2006
  6. 6. Language Engineering
  7. 7. Multiple Context Dependent Languages
  8. 8. Homogeneous Data Abstraction
  9. 9. Homogeneous Tool Integration
  10. 10. Existing Host Language
  11. 11. Context Specific Languages with Homogeneous Tool Integration
  12. 12. x=1 x=2 y=1 Package Name (2, 1) y=2 (1, 2) (2, 2)
  13. 13. aBuilder row grow. aBuilder row fill. aBuilder column grow. aBuilder column fill. aBuilder x: 1 y: 1 add: (LabelShape new text: [ :each | each name ]; borderColor: #black; borderWidth: 1; yourself). aBuilder x: 1 y: 2 w: 2 h: 1 add: (RectangleShape new borderColor: #black; borderWidth: 1; x=1 x=2 width: 200; y=1 Package Name (2, 1) height: 100; yourself) y=2 (1, 2) (2, 2)
  14. 14. row = grow. row = fill. column = grow. column = fill. (1 , 1) = label text: [ :each | each name ]; borderColor: #black; borderWidth: 1. (1 , 2) - (2 , 1) = rectangle borderColor: #black; borderWidth: 1; x=1 x=2 width: 200; y=1 Package Name (2, 1) height: 100. y=2 (1, 2) (2, 2)
  15. 15. AST Transformation
  16. 16. ➊ Pidgin syntax ‧ vocabulary ‧ semantics
  17. 17. row = grow. row = fill. column = grow. column = fill. (1 , 1) = label text: [ :each | each name ]; borderColor: #black; borderWidth: 1. (1 , 2) - (2 , 1) = rectangle borderColor: #black; borderWidth: 1; x=1 x=2 width: 200; y=1 Package Name (2, 1) height: 100. y=2 (1, 2) (2, 2)
  18. 18. shape { cols: #grow, #fill; rows: #grow, #fill; } label { position: 1 , 1; text: [ :each | each name ]; borderColor: #black; borderWidth: 1; } rectangle { position: 1 , 2; colspan: 2; borderColor: #black; x=1 x=2 borderWidth: 1; width: 200; y=1 Package Name (2, 1) height: 100; } y=2 (1, 2) (2, 2)
  19. 19. Custom Parser AST Transformation
  20. 20. ➋ Creole syntax ‧ vocabulary ‧ semantics
  21. 21. shape { cols: #grow, #fill; rows: #grow, #fill; } label { position: 1 , 1; text: [ :each | each name ]; borderColor: #black; borderWidth: 1; } rectangle { position: 1 , 2; colspan: 2; borderColor: #black; x=1 x=2 borderWidth: 1; width: 200; y=1 Package Name (2, 1) height: 100; } y=2 (1, 2) (2, 2)
  22. 22. ➌ Argot syntax ‧ vocabulary ‧ semantics
  23. 23. Transactional Memory Object Relationships
  24. 24. How does Helvetia work?
  25. 25. Rules <parse> <transform> <attribute> <bytecode> Source Smalltalk Semantic Bytecode Executable Code Parser Analysis Generation Code Traditional Smalltalk Compiler
  26. 26. Rules <parse> <transform> <attribute> <bytecode> Source Smalltalk Semantic Bytecode Executable Code Parser Analysis Generation Code Traditional Smalltalk Compiler
  27. 27. Rules <parse> <transform> <attribute> <bytecode> Source Smalltalk Semantic Bytecode Executable Code Parser Analysis Generation Code Traditional Smalltalk Compiler
  28. 28. ... <complete> <highlight> ... Rules <parse> <transform> <attribute> <bytecode> Source Smalltalk Semantic Bytecode Executable Code Parser Analysis Generation Code Traditional Smalltalk Compiler
  29. 29. ... <complete> <highlight> ... Creole path Rules Pidgin path Argot path <parse> <transform> <attribute> <bytecode> Source Smalltalk Semantic Bytecode Executable Code Parser Analysis Generation Code Traditional Smalltalk Compiler
  30. 30. Rule Types ‣ Conditional Rule Reflection ‣ Source Rule Parser, Regex ‣ AST Rule Tree Matcher
  31. 31. Rule Actions ‣ Transformations ‣ Code blocks ‣ Call other rules
  32. 32. <complete> <highlight> ... Rules <parse> <transform> <attribute> <bytecode> Source Smalltalk Semantic Bytecode Executable Code Parser Analysis Generation Code Traditional Smalltalk Compiler
  33. 33. IV + VII = XI
  34. 34. Assignments and Swapping Positional Arguments Automaton Quasiquoting and Unquoting Asynchronous Calls Regular Expression Brainfuck Roman Numbers Functional Language SQL Grammar Definition Schematic Tables Mondrian String Interpolation Object Relationships Transactional Memory Pattern Matching Tuple Spaces [http://scg.unibe.ch/research/helvetia/examples]
  35. 35. Existing Host Language
  36. 36. Multiple Context Dependent Languages
  37. 37. Homogeneous Data Abstraction
  38. 38. Homogeneous Tool Integration
  39. 39. http://scg.unibe.ch/research/helvetia
  40. 40. Rules
  41. 41. Marco Zanoli, cc-by-sa, 2.5, www.wikipedia.de, 2006
  42. 42. Marco Zanoli, cc-by-sa, 2.5, www.wikipedia.de, 2006
  43. 43. Language * Change Language * Language Box Concern * * Language Scope L. Renggli, M. Denker, O. Nierstrasz. Language Boxes: Bending the Host Language with Modular Language Changes. In SLE 2009, Denver, Colorado, October 5-6, 2009, LNCS 5969 p. 274—293, Springer, 2009.
  44. 44. http://scg.unibe.ch/research/helvetia
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×