Yapps 1 had several limitations that bothered me while writing
It was not possible to insert statements into the generated
parser. A common workaround was to write an auxilliary function
that executed those statements, and to call that function as part
of the return value calculation. For example, several of my
parsers had an “append(x,y)” function that existed solely to call
The way in which grammars were specified was rather
restrictive: a rule was a choice of clauses. Each clause was a
sequence of tokens and rule names, followed by a return value.
Optional matching had to be put into a separate rule because
choices were only made at the beginning of a rule.
Repetition had to be specified in terms of recursion. Not only
was this awkward (sometimes requiring additional rules), I had to
add a tail recursion optimization to Yapps to transform the
recursion back into a loop.
Yapps 2 addresses each of these limitations.
Statements can occur anywhere within a rule. (However, only
one-line statements are allowed; multiline blocks marked by
indentation are not.)
Grammars can be specified using any mix of sequences, choices,
tokens, and rule names. To allow for complex structures,
parentheses can be used for grouping.
Given choices and parenthesization, optional matching can be
expressed as a choice between some pattern and nothing. In
addition, Yapps 2 has the convenience syntax [A B ...] for
matching A B ... optionally.
Repetition operators * for zero or more and + for
one or more make it easy to specify repeating patterns.
It is my hope that Yapps 2 will be flexible enough to meet my needs
for another year, yet simple enough that I do not hesitate to use it.