B. Upgrading

Yapps 2.0 is not backwards compatible with Yapps 1.0. In this section are some tips for upgrading:

  1. Yapps 1.0 was distributed as a single file. Yapps 2.0 is instead distributed as two Python files: a parser generator (26k) and a parser runtime (5k). You need both files to create parsers, but you need only the runtime (yappsrt.py) to use the parsers.

  2. Yapps 1.0 supported Python 1.4 regular expressions from the regex module. Yapps 2.0 uses Python 1.5 regular expressions from the re module. The new syntax for regular expressions is not compatible with the old syntax. Andrew Kuchling has a guide to converting regular expressions on his web page.

  3. Yapps 1.0 wants a pattern and then a return value in -> <<...>>. Yapps 2.0 allows patterns and Python statements to be mixed. To convert a rule like this:

    rule R: A B C -> << E1 >>
          | X Y Z -> << E2 >>

    to Yapps 2.0 form, replace the return value specifiers with return statements:

    rule R: A B C {{ return E1 }}
          | X Y Z {{ return E2 }}

  4. Yapps 2.0 does not perform tail recursion elimination. This means any recursive rules you write will be turned into recursive methods in the parser. The parser will work, but may be slower. It can be made faster by rewriting recursive rules, using instead the looping operators * and + provided in Yapps 2.0.

Amit J Patel, amitp@cs.stanford.edu