SlideShare una empresa de Scribd logo
1 de 23
Descargar para leer sin conexión
The Spoofax
Language Workbench
Eelco Visser
Lennart Kats
Spoofax tutorial hands-on material: www.strategoxt.org/Spoofax/Devnology
Spoofax
hands-on material:
www.strategoxt.org/Spoofax/Devnology
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
Example DSL:
Spoofax tutorial hands-on material: www.strategoxt.org/Spoofax/Devnology
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
Problem: building DSLs (ct’d)
Spoofax tutorial hands-on material: www.strategoxt.org/Spoofax/Devnology
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
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
• <spoofax screenshot: lang def and lang use
in Eclipse workspace>
Spoofax tutorial hands-on material: www.strategoxt.org/Spoofax/Devnology
#1 Syntax definition
• Basic expression language
1+2+3
Expr “+” Expr -> Expr {cons(“Plus”)}
Spoofax tutorial hands-on material: www.strategoxt.org/Spoofax/Devnology
#1 Syntax definition
• Basic expression language
1+2+3
2
1
3
+
+
21
3
+
+
is that or ?
what does the abstract syntax view say?
#1 Syntax definition
• Basic expression language
1+2*3
2
1
3
+
*
21
3
*is that or ?
what does the abstract syntax view say?
+
The Spoofax Solution:
Declarative Syntax with SDF
Declarative, explicit disambigation rules
Clean abstract syntax
Composable syntax definitions
#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))
#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
#3 Equations
New syntax
New semantics
x = 2
y = 3
result = 90 * x + 30 * y
#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
x = 2
y = 3
result = 90 * x + 30 * z
#4 Error markers
(Var(“z”), “Variable z is not defined”)
transform
#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)
#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)
#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
Refinement &
Free play
Syntax definition
Static semantics
Model-to-model transformation
Code generation
Syntactic Editor Services
Semantic Editor Services
}Spoofax
www.spoofax.org

Más contenido relacionado

La actualidad más candente

La actualidad más candente (8)

T3chFest 2016 - The polyglot programmer
T3chFest 2016 - The polyglot programmerT3chFest 2016 - The polyglot programmer
T3chFest 2016 - The polyglot programmer
 
Scala-Gopher: CSP-style programming techniques with idiomatic Scala.
Scala-Gopher: CSP-style programming techniques with idiomatic Scala.Scala-Gopher: CSP-style programming techniques with idiomatic Scala.
Scala-Gopher: CSP-style programming techniques with idiomatic Scala.
 
scala-gopher: async implementation of CSP for scala
scala-gopher:  async implementation of CSP  for  scalascala-gopher:  async implementation of CSP  for  scala
scala-gopher: async implementation of CSP for scala
 
Code quailty metrics demystified
Code quailty metrics demystifiedCode quailty metrics demystified
Code quailty metrics demystified
 
The best language in the world
The best language in the worldThe best language in the world
The best language in the world
 
GUL UC3M - Introduction to functional programming
GUL UC3M - Introduction to functional programmingGUL UC3M - Introduction to functional programming
GUL UC3M - Introduction to functional programming
 
201801 CSE240 Lecture 14
201801 CSE240 Lecture 14201801 CSE240 Lecture 14
201801 CSE240 Lecture 14
 
Csp scala wixmeetup2016
Csp scala wixmeetup2016Csp scala wixmeetup2016
Csp scala wixmeetup2016
 

Destacado (6)

anheuser-busch 2006AR_LetterToShareholders
anheuser-busch 2006AR_LetterToShareholdersanheuser-busch 2006AR_LetterToShareholders
anheuser-busch 2006AR_LetterToShareholders
 
Presentation ASB
Presentation ASBPresentation ASB
Presentation ASB
 
New creative economy pwp
New creative economy pwpNew creative economy pwp
New creative economy pwp
 
DME
DMEDME
DME
 
Irlande Johanne Mathilde
Irlande Johanne MathildeIrlande Johanne Mathilde
Irlande Johanne Mathilde
 
What's New in Search Engine Market (2009 review)
What's New in Search Engine Market (2009 review)What's New in Search Engine Market (2009 review)
What's New in Search Engine Market (2009 review)
 

Similar a Spoofax: ontwikkeling van domeinspecifieke talen in Eclipse

Building DSLs On CLR and DLR (Microsoft.NET)
Building DSLs On CLR and DLR (Microsoft.NET)Building DSLs On CLR and DLR (Microsoft.NET)
Building DSLs On CLR and DLR (Microsoft.NET)
Vitaly Baum
 
The Art Of Readable Code
The Art Of Readable CodeThe Art Of Readable Code
The Art Of Readable Code
Baidu, Inc.
 
Combinators, DSLs, HTML and F#
Combinators, DSLs, HTML and F#Combinators, DSLs, HTML and F#
Combinators, DSLs, HTML and F#
Robert Pickering
 
AestasIT - Internal DSLs in Scala
AestasIT - Internal DSLs in ScalaAestasIT - Internal DSLs in Scala
AestasIT - Internal DSLs in Scala
Dmitry Buzdin
 
Core .NET Framework 4.0 Enhancements
Core .NET Framework 4.0 EnhancementsCore .NET Framework 4.0 Enhancements
Core .NET Framework 4.0 Enhancements
Robert MacLean
 
Cadence GenusTutorial------------ .pdf.pdf
Cadence GenusTutorial------------ .pdf.pdfCadence GenusTutorial------------ .pdf.pdf
Cadence GenusTutorial------------ .pdf.pdf
SamHoney6
 
Linq 1224887336792847 9
Linq 1224887336792847 9Linq 1224887336792847 9
Linq 1224887336792847 9
google
 

Similar a Spoofax: ontwikkeling van domeinspecifieke talen in Eclipse (20)

Building DSLs On CLR and DLR (Microsoft.NET)
Building DSLs On CLR and DLR (Microsoft.NET)Building DSLs On CLR and DLR (Microsoft.NET)
Building DSLs On CLR and DLR (Microsoft.NET)
 
The Art Of Readable Code
The Art Of Readable CodeThe Art Of Readable Code
The Art Of Readable Code
 
Combinators, DSLs, HTML and F#
Combinators, DSLs, HTML and F#Combinators, DSLs, HTML and F#
Combinators, DSLs, HTML and F#
 
Introducing BinarySortedMultiMap - A new Flink state primitive to boost your ...
Introducing BinarySortedMultiMap - A new Flink state primitive to boost your ...Introducing BinarySortedMultiMap - A new Flink state primitive to boost your ...
Introducing BinarySortedMultiMap - A new Flink state primitive to boost your ...
 
AestasIT - Internal DSLs in Scala
AestasIT - Internal DSLs in ScalaAestasIT - Internal DSLs in Scala
AestasIT - Internal DSLs in Scala
 
Measuring Your Code
Measuring Your CodeMeasuring Your Code
Measuring Your Code
 
Measuring Your Code 2.0
Measuring Your Code 2.0Measuring Your Code 2.0
Measuring Your Code 2.0
 
Software Language Design & Engineering: Mobl & Spoofax
Software Language Design & Engineering: Mobl & SpoofaxSoftware Language Design & Engineering: Mobl & Spoofax
Software Language Design & Engineering: Mobl & Spoofax
 
Hands on Mahout!
Hands on Mahout!Hands on Mahout!
Hands on Mahout!
 
CoCoViLa @ devclub.eu
CoCoViLa @ devclub.euCoCoViLa @ devclub.eu
CoCoViLa @ devclub.eu
 
Core .NET Framework 4.0 Enhancements
Core .NET Framework 4.0 EnhancementsCore .NET Framework 4.0 Enhancements
Core .NET Framework 4.0 Enhancements
 
Scam 08
Scam 08Scam 08
Scam 08
 
(1) c sharp introduction_basics_dot_net
(1) c sharp introduction_basics_dot_net(1) c sharp introduction_basics_dot_net
(1) c sharp introduction_basics_dot_net
 
C sharp 8.0 new features
C sharp 8.0 new featuresC sharp 8.0 new features
C sharp 8.0 new features
 
More Data, More Problems: Evolving big data machine learning pipelines with S...
More Data, More Problems: Evolving big data machine learning pipelines with S...More Data, More Problems: Evolving big data machine learning pipelines with S...
More Data, More Problems: Evolving big data machine learning pipelines with S...
 
Cadence GenusTutorial------------ .pdf.pdf
Cadence GenusTutorial------------ .pdf.pdfCadence GenusTutorial------------ .pdf.pdf
Cadence GenusTutorial------------ .pdf.pdf
 
Python basics
Python basicsPython basics
Python basics
 
Linq 1224887336792847 9
Linq 1224887336792847 9Linq 1224887336792847 9
Linq 1224887336792847 9
 
Natural Language Processing with CNTK and Apache Spark with Ali Zaidi
Natural Language Processing with CNTK and Apache Spark with Ali ZaidiNatural Language Processing with CNTK and Apache Spark with Ali Zaidi
Natural Language Processing with CNTK and Apache Spark with Ali Zaidi
 
Michael Hall [InfluxData] | Become an InfluxDB Pro in 20 Minutes | InfluxDays...
Michael Hall [InfluxData] | Become an InfluxDB Pro in 20 Minutes | InfluxDays...Michael Hall [InfluxData] | Become an InfluxDB Pro in 20 Minutes | InfluxDays...
Michael Hall [InfluxData] | Become an InfluxDB Pro in 20 Minutes | InfluxDays...
 

Más de Devnology

Slides Felienne Hermans Symposium EWI
Slides Felienne Hermans Symposium EWISlides Felienne Hermans Symposium EWI
Slides Felienne Hermans Symposium EWI
Devnology
 
Devnology auteursrecht en open source 20130205
Devnology auteursrecht en open source 20130205Devnology auteursrecht en open source 20130205
Devnology auteursrecht en open source 20130205
Devnology
 
Learn a language : LISP
Learn a language : LISPLearn a language : LISP
Learn a language : LISP
Devnology
 
Devnology Back to School IV - Agility en Architectuur
Devnology Back to School IV - Agility en ArchitectuurDevnology Back to School IV - Agility en Architectuur
Devnology Back to School IV - Agility en Architectuur
Devnology
 
Introduction to Software Evolution: The Software Volcano
Introduction to Software Evolution: The Software VolcanoIntroduction to Software Evolution: The Software Volcano
Introduction to Software Evolution: The Software Volcano
Devnology
 
Devnology Workshop Genpro 2 feb 2011
Devnology Workshop Genpro 2 feb 2011Devnology Workshop Genpro 2 feb 2011
Devnology Workshop Genpro 2 feb 2011
Devnology
 
Devnology Coding Dojo 05-01-2011
Devnology Coding Dojo 05-01-2011Devnology Coding Dojo 05-01-2011
Devnology Coding Dojo 05-01-2011
Devnology
 
Experimenting with Augmented Reality
Experimenting with Augmented RealityExperimenting with Augmented Reality
Experimenting with Augmented Reality
Devnology
 
Unit testing and MVVM in Silverlight
Unit testing and MVVM in SilverlightUnit testing and MVVM in Silverlight
Unit testing and MVVM in Silverlight
Devnology
 
mobl: Een DSL voor mobiele applicatieontwikkeling
mobl: Een DSL voor mobiele applicatieontwikkelingmobl: Een DSL voor mobiele applicatieontwikkeling
mobl: Een DSL voor mobiele applicatieontwikkeling
Devnology
 

Más de Devnology (20)

What do we really know about the differences between static and dynamic types?
What do we really know about the differences between static and dynamic types?What do we really know about the differences between static and dynamic types?
What do we really know about the differences between static and dynamic types?
 
Meetup at SIG: Meten is weten
Meetup at SIG: Meten is wetenMeetup at SIG: Meten is weten
Meetup at SIG: Meten is weten
 
Software Operation Knowledge
Software Operation KnowledgeSoftware Operation Knowledge
Software Operation Knowledge
 
Slides Felienne Hermans Symposium EWI
Slides Felienne Hermans Symposium EWISlides Felienne Hermans Symposium EWI
Slides Felienne Hermans Symposium EWI
 
Devnology auteursrecht en open source 20130205
Devnology auteursrecht en open source 20130205Devnology auteursrecht en open source 20130205
Devnology auteursrecht en open source 20130205
 
The top 10 security issues in web applications
The top 10 security issues in web applicationsThe top 10 security issues in web applications
The top 10 security issues in web applications
 
Hacking Smartcards & RFID
Hacking Smartcards & RFIDHacking Smartcards & RFID
Hacking Smartcards & RFID
 
Learn a language : LISP
Learn a language : LISPLearn a language : LISP
Learn a language : LISP
 
Learn a language : LISP
Learn a language : LISPLearn a language : LISP
Learn a language : LISP
 
Devnology Back to School: Empirical Evidence on Modeling in Software Development
Devnology Back to School: Empirical Evidence on Modeling in Software DevelopmentDevnology Back to School: Empirical Evidence on Modeling in Software Development
Devnology Back to School: Empirical Evidence on Modeling in Software Development
 
Devnology Back to School IV - Agility en Architectuur
Devnology Back to School IV - Agility en ArchitectuurDevnology Back to School IV - Agility en Architectuur
Devnology Back to School IV - Agility en Architectuur
 
Devnology Back to School III : Software impact
Devnology Back to School III : Software impactDevnology Back to School III : Software impact
Devnology Back to School III : Software impact
 
Devnology back toschool software reengineering
Devnology back toschool software reengineeringDevnology back toschool software reengineering
Devnology back toschool software reengineering
 
Introduction to Software Evolution: The Software Volcano
Introduction to Software Evolution: The Software VolcanoIntroduction to Software Evolution: The Software Volcano
Introduction to Software Evolution: The Software Volcano
 
Devnology Workshop Genpro 2 feb 2011
Devnology Workshop Genpro 2 feb 2011Devnology Workshop Genpro 2 feb 2011
Devnology Workshop Genpro 2 feb 2011
 
Devnology Coding Dojo 05-01-2011
Devnology Coding Dojo 05-01-2011Devnology Coding Dojo 05-01-2011
Devnology Coding Dojo 05-01-2011
 
Experimenting with Augmented Reality
Experimenting with Augmented RealityExperimenting with Augmented Reality
Experimenting with Augmented Reality
 
Unit testing and MVVM in Silverlight
Unit testing and MVVM in SilverlightUnit testing and MVVM in Silverlight
Unit testing and MVVM in Silverlight
 
mobl: Een DSL voor mobiele applicatieontwikkeling
mobl: Een DSL voor mobiele applicatieontwikkelingmobl: Een DSL voor mobiele applicatieontwikkeling
mobl: Een DSL voor mobiele applicatieontwikkeling
 
Devnology Fitnesse workshop
Devnology Fitnesse workshopDevnology Fitnesse workshop
Devnology Fitnesse workshop
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

Spoofax: ontwikkeling van domeinspecifieke talen in Eclipse

  • 1. The Spoofax Language Workbench Eelco Visser Lennart Kats Spoofax tutorial 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
  • 23. Syntax definition Static semantics Model-to-model transformation Code generation Syntactic Editor Services Semantic Editor Services }Spoofax www.spoofax.org