Your SlideShare is downloading. ×
Spoofax: ontwikkeling van domeinspecifieke talen in Eclipse
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Spoofax: ontwikkeling van domeinspecifieke talen in Eclipse

871
views

Published on

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
871
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
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 Eelco Visser Lennart Kats 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: • Mobile phone • Web • Financial • Printer design • ... Spoofax tutorial hands-on material: www.strategoxt.org/Spoofax/Devnology Can offer: • Specialized syntax • Specialized analysis • Specialized optimizations • Platform independence
  • 4. Example DSL: Spoofax tutorial hands-on material: www.strategoxt.org/Spoofax/Devnology
  • 5. Syntax definition ★ concrete + abstract syntax Static semantics ★ error checking ★ name resolution ★ type analysis Model-to-model transformation ★ express constructs in core language Code generation ★ translate core language models to implementation Problem: building DSLs parser generators meta- programming languages meta- programming libraries template 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 • syntax highlighting • syntax checking • outline view • bracket matching, insertion • automatic indentation • syntax completion • ... semantic editor services • error marking • reference resolving • hover help • mark occurrences • content completion • refactoring • ... Spoofax tutorial hands-on material: www.strategoxt.org/Spoofax/Devnology
  • 8. Syntax definition Static semantics Model-to-model transformation Code generation Syntactic Editor Services Semantic Editor Services }Spoofax 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 2 1 3 + + 21 3 + + is that or ? what does the abstract syntax view say?
  • 12. #1 Syntax definition • Basic expression language 1+2*3 2 1 3 + * 21 3 *is that or ? 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 Tip. Some other operators: subtS, mulS, divS, gt, lt, eq Transform 1+2 to <addition of> 1 and 2: calc: Add(Int(i), Int(j)) -> Int(<addS> (i, j))
  • 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 New syntax New semantics x = 2 y = 3 result = 90 * x + 30 * y
  • 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) calc: Var(x) -> <GetValue> x New syntax New semantics
  • 18. x = 2 y = 3 result = 90 * x + 30 * z #4 Error markers (Var(“z”), “Variable z is not defined”) transform
  • 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 Code generation Syntactic Editor Services Semantic Editor Services }Spoofax www.spoofax.org