D. History

Yapps 1 had several limitations that bothered me while writing parsers:

  1. 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 “x.append(y)”.
  2. 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.
  3. Optional matching had to be put into a separate rule because choices were only made at the beginning of a rule.
  4. 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.

  1. Statements can occur anywhere within a rule. (However, only one-line statements are allowed; multiline blocks marked by indentation are not.)
  2. 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.
  3. 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.
  4. 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.

Amit J Patel, amitp@cs.stanford.edu