Mixing multiple languages and notations in a sin-
gle program has traditionally been hard with textual
programming languages. It is a difficult task to com-
pose textual syntaxes to form a well-defined grammar.
On the other hand, with projectional editing it is natu-
ral to combine projections because there is no require-
ment stating that the syntax should be unambiguous.
Projectional editors offer a completely different
editing experience compared to traditional text edi-
tors, and this way of editing can be seen as difficult
and cumbersome by developers. Research on current
limitations of projectional editors (as found in MPS)
shows that there are some real issues, and especially
(Völter et al., 2014) highlights many of them. How-
ever, current research seems to mostly focus on com-
paring features which are lacking or difficult in pro-
jectional editors, but which are default or simple in
text editors (such as e.g. support for copy/paste). In
this paper we will look at it the other way; there are
a lot fewer restrictions on the concrete syntax with
projectional editors compared to textual ones and this
may cause problems. The freedom in defining the
concrete syntax is not problematic for the computer,
but it can cause problems for the language user.
Not having to worry about unparseable programs
can be seen as a benefit of projectional editing, but
we argue it is only beneficial to the language designer
and that it can actually be a hinderance to the user.
Ambiguous syntax is not only a problem for parsers,
but a problem that affects humans as well. With pro-
jectional editors there are no sanity checks regarding
the concrete syntax. In this paper we present a solu-
tion to this problem that we developed in (Guttorm-
sen, 2016), showing how projectional editors can be
extended with sanity checks. These checks makes it
possible to automatically identify ambiguities in the
concrete syntax.
Surveying related work shows that there have
been similar experiments on automatic analysis and
model-checking. (Völter, 2014) discusses some dif-
ferent methods for analyzing and checking models,
but the methods discussed are aimed at analyzing pro-
grams—not languages. It differs from our work in
that we focus on analyzing the concrete syntax of lan-
guages.
So the novel contribution of this paper is its fo-
cus on the user when looking at the quality of a con-
crete syntax. This is opposed to the focus on machine
analyzability. The solution we implemented is built
around projectional editors, but the ideas are also ap-
plicable to non-projectional approaches like Xtext.
We continue by discussing text analysis from a
human-machine point of view in Section 2. After that,
we look into human-human communication in Sec-
tion 3, and ambiguity as a problem. We provide a so-
lution in Section 4, before summarizing in Section 5.
2 TEXT ANALYSIS AND
PROCESSING
In order to get a better understanding of the issues
related to projectional editors, we will look into the
handling of program texts and syntax in general.
Handling of syntax started with the advent of com-
pilers, which analyse the input text, make sense out
of it and generate some output text. As far as the in-
put text is concerned, grammars were found to be the
best theory to describe the structure of the input. Sev-
eral classes of grammars were identified. An example
is the Chomsky classification, which was introduced
by Noam Chomsky. He divided grammars into four
classes: unrestricted, context-sensitive, context-free,
and regular grammars.
Finally, for most applications it turned out the con-
text free grammars would do the trick for defining
the syntax, balancing expressivity and analyzability.
However, even those were not easily analyzable in all
cases, and for automatic generation of analysis tools
more restricted classes were introduced. LL(1) was
identified to fit for top-down parsing, and LR(1) for
bottom-up parsing. Finally, analysis techniques be-
came more advanced and LL* tools appeared (e.g
ANTLR (Parr and Quong, 1995)).
At the same time, it turned out that the concrete
syntax was too detailed for efficient analysis. This led
to the focus onto the definition of abstract syntax, in
order to capture the essential features of the language.
From there, the relation to the concrete syntax was
given by a mapping.
To handle graphical languages, meta-modelling
was introduced which started with the abstract syntax
(called meta-model), and attached the concrete syn-
tax to the abstract syntax. This way, the traditional
path from concrete syntax via abstract syntax and ab-
stract code to concrete code was reversed at the be-
ginning. Now, the abstract syntax was the central el-
ement. Thus, it was possible to define graphical lan-
guages, like UML. As an example we show the graph-
ical syntax for a simple class diagram modelling a li-
brary in Fig. 1, here defined using EMF (which is es-
sentially a subset of UML class diagrams). The class
diagram is just the presentation of the abstract syntax,
whose structure is shown in Fig. 2.
Defining a projectional editor involves specifying
how each element of the abstract syntax should be
presented. The editor definition specifies how the user
input should be translated into changes in the abstract
MODELSWARD 2017 - 5th International Conference on Model-Driven Engineering and Software Development
516