• Like

Loading…

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

Spoofax: ontwikkeling van domeinspecifieke talen in Eclipse

  • 854 views
Uploaded on

 

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
854
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
5
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. The Spoofax Language Workbench Lennart Kats Eelco Visser Spoofax tutorial hands-on material: www.strategoxt.org/Spoofax/Devnology
  • 2. Spoofax hands-on material: www.strategoxt.org/Spoofax/Devnology
  • 3. Domain-Specific Languages (DSLs) Domain: Can offer: • Mobile phone • Specialized syntax • Web • Specialized analysis • Financial • Specialized • Printer design optimizations • ... • Platform independence Spoofax tutorial hands-on material: www.strategoxt.org/Spoofax/Devnology
  • 4. Example DSL: Spoofax tutorial hands-on material: www.strategoxt.org/Spoofax/Devnology
  • 5. Problem: building DSLs Syntax definition ★ concrete + abstract syntax Static semantics parser ★ error checking generators ★ name resolution meta- ★ type analysis programming libraries Model-to-model transformation meta- programming ★ express constructs in core language Code generation languages template ★ translate core language models to implementation engines Spoofax tutorial hands-on material: www.strategoxt.org/Spoofax/Devnology
  • 6. Problem: building DSLs (ct’d) Spoofax tutorial hands-on material: www.strategoxt.org/Spoofax/Devnology
  • 7. 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 • ... • ... Spoofax tutorial hands-on material: www.strategoxt.org/Spoofax/Devnology
  • 8. Syntax definition Static semantics Model-to-model transformation Spoofax Code generation Syntactic Editor Services Semantic Editor Services how can we make these things cheaply? Spoofax tutorial hands-on material: www.strategoxt.org/Spoofax/Devnology
  • 9. • <spoofax screenshot: lang def and lang use in Eclipse workspace> Spoofax tutorial hands-on material: www.strategoxt.org/Spoofax/Devnology
  • 10. #1 Syntax definition • Basic expression language 1+2+3 Expr “+” Expr -> Expr {cons(“Plus”)} Spoofax tutorial hands-on material: www.strategoxt.org/Spoofax/Devnology
  • 11. #1 Syntax definition • Basic expression language + + 1+2+3 is that or ? 1 + + 3 2 3 1 2 what does the abstract syntax view say?
  • 12. #1 Syntax definition • Basic expression language + * 1+2*3 is that or ? 1 * + 3 2 3 1 2 what does the abstract syntax view say?
  • 13. The Spoofax Solution: Declarative Syntax with SDF Declarative, explicit disambigation rules Clean abstract syntax Composable syntax definitions
  • 14. #2 Transformation Transform 1+2 to <addition of> 1 and 2: calc: Add(Int(i), Int(j)) -> Int(<addS> (i, j)) Tip. Some other operators: subtS, mulS, divS, gt, lt, eq
  • 15. #2 Transformation Transform 1+2 to <addition of> 1 and 2: calc: Add(Int(i), Int(j)) -> Int(<addS> (i, j)) calculate = bottomup(try(calc)) Tip. Some other operators: subtS, mulS, divS, gt, lt, eq
  • 16. #3 Equations x = 2 y = 3 result = 90 * x + 30 * y New syntax New semantics
  • 17. #3 Equations x = 2 y = 3 result = 90 * x + 30 * y Assign(“x”, INT(2)) calc: Assign(x, e) -> e where rules(GetValue: x -> e) New syntax New semantics calc: Var(x) -> <GetValue> x
  • 18. #4 Error markers x = 2 y = 3 result = 90 * x + 30 * z transform (Var(“z”), “Variable z is not defined”)
  • 19. #4 Error markers analyze = topdown(try(record-var)) record-var: Assign(x, e) -> Assign(x, e) with rules( GetVar :+ x -> e ) constraint-errors = collect-all(constraint-error, conc) constraint-error: Var(x) -> (x, $[Variable [x] is not defined]) where not(<GetVar> x)
  • 20. #4 Error markers #5 Refinement analyze = topdown(try(record-var)) record-var: Assign(x, e) -> Assign(x, e) with rules( GetVar :+ x -> e ) constraint-errors = collect-all(constraint-error, conc) constraint-error: Var(x) -> (x, $[Variable [x] is not defined]) where not(<GetVar> x)
  • 21. #4 Error markers #5 Refinement editor-resolve: (Var(x), position, ast, path, project-path) -> target where target := <GetVar> x editor-complete: (Var(x), position, ast, path, project-path) -> proposals where proposals := <all-keys-GetVar> x
  • 22. Refinement & Free play
  • 23. Syntax definition Static semantics Model-to-model transformation Spoofax Code generation Syntactic Editor Services Semantic Editor Services www.spoofax.org