Skip to content

Commit

Permalink
Merge pull request #22 from spoofax-shell/finish-spoofax-sec
Browse files Browse the repository at this point in the history
[RDY] Finish Spoofax section with subsection on Editor Services
  • Loading branch information
Hjdskes committed Apr 29, 2016
2 parents f787b85 + 007e4a6 commit 9486962
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 20 deletions.
23 changes: 5 additions & 18 deletions research/05-problem-ana.tex
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,13 @@ \subsubsection{Language specific additional commands}
language is a DSL. It is clear therefore that a different approach
should be considered.

\begin{figure}[htbp]
\centering
\includegraphics[width=0.5\textwidth]{menu-actions.png}
\caption{A menu action for the paplj language defined using
Spoofax. The bottom window shows the menu definition, the top
window shows a program written in paplj.}
\label{fig:menu-actions}
\end{figure}

One possible solution is to allow for language specific configurations
that are loaded and used during the generation process of a REPL for
that language. This is similar to something that currently exists in
Spoofax: when one creates a language, there is the possibility to
define menu buttons and bind them to Stratego strategies
(\cref{sec:orgheadline5}). For example, one can define a menu button
``Run'' to run the expression that is currently selected (see
\cref{fig:menu-actions}), or a ``Desugar'' button to desugar the
program that is currently open. In the same way, one may define a
``load-file'' command for a REPL which is bound to a Stratego
strategy.
that language. This can be done by extending the editor services
discussed in \cref{sec:editor-serv} with REPL commands: similar to
menu actions, where one can define menu button ``Run'' to run a
program, one may define a ``load-file'' command and bind it to an
action.

\subsubsection{Redefining terms bound to names}
\label{sec:redef-cont-bound}
Expand Down
35 changes: 34 additions & 1 deletion research/notes.org
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ language specification portion of the compiler construction course at
the TU Delft. The slides can be found here:
[[http://tudelft-in4303.github.io/lectures/specification/]].]. The parts
of a language specification are:

1. [[#sec:syntax-def][Syntax Definition]]: Specifying the syntax of a language.
2. [[#sec:static-analysis][Static Semantics]]: Describing the static analysis part of a
language (type checking, name binding and variable scoping).
Expand All @@ -38,6 +39,8 @@ of a language specification are:
rules.
4. [[#sec:dynamic-semantics][Dynamic Semantics]]: Defining what the language does upon execution.

After that, the section concludes with a description of [[#sec:editor-serv][Editor
Services in Spoofax]].
** Syntax Definition
:PROPERTIES:
:CUSTOM_ID: sec:syntax-def
Expand Down Expand Up @@ -69,7 +72,7 @@ and pretty-printers for mapping ASTs back to text. However, due to its
declarative nature, SDF3 is not limited to generating parsers and
pretty printers: it can also be used for error recovery
rules\nbsp\cite{deJonge12}, syntax highlighting rules and folding
rules for editors.
rules for editors (see section [[#sec:editor-serv]]).

All of the other parts of Spoofax use the AST that is produced by a
parser generated from an SDF3 specification.
Expand Down Expand Up @@ -261,6 +264,36 @@ the parameter in the environment and binding the =this= variable to
the object on which the method is called. Exactly how $e$ evaluates to
$v'$ is defined using other rules, which are left out in this example.
#+LATEX: \lstset{numbers=none}

** Editor Services
:PROPERTIES:
:CUSTOM_ID: sec:editor-serv
:END:
This section concludes with a brief description of editor services,
which provide the IDE support for languages defined in
Spoofax. Examples of such services include an outline view, menus in
which one can bind actions to menu buttons (see figure
[[fig:menu-actions]]), but also syntax highlighting and code folding
rules[fn:editor-serv-web:More services are listed on the Spoofax
website: http://www.metaborg.org/spoofax/editor-services/].

#+ATTR_LATEX: :width 0.6\textwidth
#+CAPTION: A menu action for the paplj language defined using Spoofax. The bottom window shows the menu definition, the top window shows a program written in paplj.
#+NAME: fig:menu-actions
[[./img/menu-actions.png]]

Editor services are defined using a DSL, shown in the bottom window of
figure [[fig:menu-actions]]. In the case of menus, their actions are
specified using Stratego, and via Stratego the actions can even be
specified in Java. As such, Spoofax allows for defining arbitrarily
complex IDE actions.

Many of these editor services such as syntax highlighting and code
folding rules can be derived from the syntax
definition\nbsp\cite{Kats10c}, and can be further customized if
needed. Taken together with the language definition, the editor
services provide a language with a complete and state-of-the-art IDE
experience\nbsp\cite{Kats10a}.
* References
:PROPERTIES:
:UNNUMBERED: t
Expand Down
14 changes: 14 additions & 0 deletions research/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,20 @@ @article{deJonge12
publisher = {ACM},
address = {New York, NY, USA},
}
@inproceedings{Kats10c,
title = "{Domain-Specific Languages for Composable Editor Plugins}",
author = {Lennart C. L. Kats and Karl Trygve Kalleberg and Eelco Visser},
year = {2010},
doi = {http://dx.doi.org/10.1016/j.entcs.2010.08.038},
tags = {C++, domain-specific language},
researchr = {http://researchr.org/publication/KatsKV10},
cites = {0},
citedby = {0},
journal = {Electronic Notes in Theoretical Computer Science},
volume = {253},
number = {7},
pages = {149-163},
}
@inproceedings{Kats10b,
title = "{Pure and declarative syntax definition: paradise lost and regained}",
author = {Lennart C. L. Kats and Eelco Visser and Guido Wachsmuth},
Expand Down
35 changes: 34 additions & 1 deletion research/spoofax-org-export.tex
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
the TU Delft. The slides can be found here:
\url{http://tudelft-in4303.github.io/lectures/specification/}.}. The parts
of a language specification are:

\begin{enumerate}
\item \hyperref[sec:syntax-def]{Syntax Definition}: Specifying the syntax of a language.
\item \hyperref[sec:static-analysis]{Static Semantics}: Describing the static analysis part of a
Expand All @@ -31,6 +32,8 @@
\item \hyperref[sec:dynamic-semantics]{Dynamic Semantics}: Defining what the language does upon execution.
\end{enumerate}

After that, the section concludes with a description of \hyperref[sec:editor-serv]{Editor
Services in Spoofax}.
\subsection{Syntax Definition}
\label{sec:syntax-def}
The first part of the specification of a language is its syntax. The
Expand Down Expand Up @@ -61,7 +64,7 @@ \subsubsection{SDF3: syntax definition in Spoofax}
declarative nature, SDF3 is not limited to generating parsers and
pretty printers: it can also be used for error recovery
rules~\cite{deJonge12}, syntax highlighting rules and folding
rules for editors.
rules for editors (see section \ref{sec:editor-serv}).

All of the other parts of Spoofax use the AST that is produced by a
parser generated from an SDF3 specification.
Expand Down Expand Up @@ -241,3 +244,33 @@ \subsubsection{DynSem: rule-based dynamic semantics}
the object on which the method is called. Exactly how \(e\) evaluates to
\(v'\) is defined using other rules, which are left out in this example.
\lstset{numbers=none}

\subsection{Editor Services}
\label{sec:editor-serv}
This section concludes with a brief description of editor services,
which provide the IDE support for languages defined in
Spoofax. Examples of such services include an outline view, menus in
which one can bind actions to menu buttons (see figure
\ref{fig:menu-actions}), but also syntax highlighting and code folding
rules\footnote{More services are listed on the Spoofax
website: \url{http://www.metaborg.org/spoofax/editor-services/}}.

\begin{figure}[htb]
\centering
\includegraphics[width=0.6\textwidth]{./img/menu-actions.png}
\caption{\label{fig:menu-actions}
A menu action for the paplj language defined using Spoofax. The bottom window shows the menu definition, the top window shows a program written in paplj.}
\end{figure}

Editor services are defined using a DSL, shown in the bottom window of
figure \ref{fig:menu-actions}. In the case of menus, their actions are
specified using Stratego, and via Stratego the actions can even be
specified in Java. As such, Spoofax allows for defining arbitrarily
complex IDE actions.

Many of these editor services such as syntax highlighting and code
folding rules can be derived from the syntax
definition~\cite{Kats10c}, and can be further customized if
needed. Taken together with the language definition, the editor
services provide a language with a complete and state-of-the-art IDE
experience~\cite{Kats10a}.

0 comments on commit 9486962

Please sign in to comment.