Examples from Spoofax "Stratego Tutorial/Reference" manual, worked in Spoofax Eclipse IDE. http://studioinfinity.org/SPL
Go to file
Glen Whitney 56b8b921dc docs: Initiate building documentation with mkdocs
Also lay out the structure of the documentation and supply a decent
  introduction. Also (unsuccessfully) attempt to get the first example of
  a Stratego transformation from the manual implemented and documented.
2021-01-12 08:41:01 -08:00
.mvn init: Spoofax language project as generated 2020-12-15 00:24:59 -08:00
docrefs docs: Initiate building documentation with mkdocs 2021-01-12 08:41:01 -08:00
editor docs: Initiate building documentation with mkdocs 2021-01-12 08:41:01 -08:00
src/main/strategies/spoofax_prop/strategies init: Spoofax language project as generated 2020-12-15 00:24:59 -08:00
syntax docs: Initiate building documentation with mkdocs 2021-01-12 08:41:01 -08:00
trans docs: Initiate building documentation with mkdocs 2021-01-12 08:41:01 -08:00
.gitignore docs: Initiate building documentation with mkdocs 2021-01-12 08:41:01 -08:00
metaborg.yaml init: Spoofax language project as generated 2020-12-15 00:24:59 -08:00
mkdocs.yml docs: Initiate building documentation with mkdocs 2021-01-12 08:41:01 -08:00
pom.xml init: Spoofax language project as generated 2020-12-15 00:24:59 -08:00
prop.spl feat: Provide grammar producing aterms with signature matching Chap 4 2020-12-15 21:58:07 -08:00
README.md docs: Initiate building documentation with mkdocs 2021-01-12 08:41:01 -08:00

Title: The Spoofax Propositional Language Next: syntax/Spoofax-Propositional-Language.sdf3

Stratego Transformations in the Spoofax Eclipse IDE

The Stratego Tutorial/Reference {! docrefs/manual.md !} in the official Spoofax documentation presents a comprehensive overview of the Stratego approach to abstract syntax tree (AST) transformations. It employs a running example of an abstract syntax intended to represent classical Propositional Logic, which we will dub here the "Spoofax Propositional Language." The manual introduces the concepts of rules and strategies for applying them, and then shows how both of those facilities can be created from more primitive operations of term matching and replacement. Every step of the way is illustrated with actual, working Stratego programs.

There are, however, two catches for a newcomer trying to learn Spoofax and Stratego for the first time:

  1. All of the examples are worked in an older framework ("Stratego/XT") which has a rather different collection of tools than the current implementation of Spoofax in the Eclipse IDE.
  2. Unlike with the Calc example language used for the explication of the Syntax Definition Language SDF3, there does not seem to be any publicly available repository containing the worked examples to follow along with.

This Gitea repository aims to fill both gaps. It can be cloned as an Eclipse project (note the git root is at the project level rather than in the directory above the project, as may be more common; in other words, this repository should be cloned within an existing Eclipse workspace, rather than as the workspace itself). Within that project, (ultimately) every example from the Stratego Tutorial manual starting from Section 4 on can be executed directly. And this (Mkdocs-generated) documentation seeks to clarify the ways that Stratego transformations may be run in the Spoofax/Eclipse IDE environment, serving as a supplement/replacement for the portions of the manual that were specific to Stratego/XT.

Abstract syntax

Let's begin by recalling the abstract syntax of the Spoofax Propositional Language (SPL), as defined at the top of {! docrefs/sec4.1.md !} of the manual. It consists of the following signature of constructors:

{! src-gen/signatures/Spoofax-Propositional-Language-sig.str ---
  start: '(signature[\s]*)$'
  end: '^(\s*Eq\s*:.*)'
!}

Continue reading in the latest released SPL documentation to see how to define and run Stratego transformations on ASTs of this language.