recgen.icn: Program to generate context-free recognizer

January 28, 1991; Ralph E. Griswold
See also: pargen.icn
This file is in the public domain.
   This program reads a context-free BNF grammar and produces an Icon
program that is a recognizer for the corresponding language.

   Nonterminal symbols are are enclosed in angular brackets. Vertical
bars separate alternatives.  All other characters are considered to
be terminal symbols.  The nonterminal symbol on the first line is
taken to be the goal.

   An example is:

     <expression>::=<term>|<term>+<expression>
     <term>::=<element>|<element>*<term>
     <element>::=x|y|z|(<expression>)

   Characters in nonterminal names are limited to letters and underscores.
An underscore is appended for the recognizing procedure name to avoid
possible collisions with Icon function names.

   Lines beginning with an = are passed through unchanged. This allows
Icon code to be placed in the recognizer.
____________________________________________________________

Limitations:

   Left recursion in the grammar may cause the recognizer to loop.
There is no check that all nonterminal symbols that are referenced
are defined or for duplicate definitions.
____________________________________________________________

Reference:

   The Icon Programming Language, Second Edition, Ralph E. and Madge T.
   Griswold, Prentice-Hall, 1990. pp. 180-187.

Source code | Program Library Page | Icon Home Page