Index of /~comp412/Labs/LL1Skeleton

      Name                    Last modified       Size  Description

[DIR] Parent Directory 15-Nov-2009 19:26 - [TXT] LL1Table.h 25-Oct-2009 20:38 4k [TXT] Parens.h 25-Oct-2009 20:38 3k [TXT] RRCEG.h 25-Oct-2009 20:38 4k [TXT] Skeleton.c 25-Oct-2009 20:38 5k

LL(1) Skeleton Parser for Programming Assignment # 2
COMP 412, Fall 2007

Information on the Skeleton Parser and Its Use

The skeleton parser is written in C, for compilation with 
the gcc compiler. [It was tested with gcc; it should work
with other compilers, but ...]  It consists of two files:

  Skeleton.c -- contains all the unchanging code

  LL1Table.h -- contains the definitions for a specific 
                grammar.  (RRCEG.h and Parens.h are 
                examples that can be copied over the 
                LL1Table.h file to show different 
                behaviors.)

Your LL(1) Table Generator should produce all of the 
declarations in LL1Table.h.  The examples show the full
set of definitions that the skeleton parser needs,
including 

1.  Definitions for the terminals and nonterminals

    Note that the names "START", "ENDOFFILE", and
    "EPSILON" must be in specific places in the ordered
    set of symbols (first, second to last, and last,
    respectively).  Nonterminals precede terminals in 
    the order.

2.  Definitions of some grammar-related constants

3.  A table of symbol names, in order by their defined
    ordinal constants (see 1 above).

4.  The LHS and RHS tables that allow the skeleton parser
    to push the appropriate symbols on the stack when it
    expands a nonterminal.  (Technically, LHS is not needed
    for that action, but it is useful when the parser tries
    to print out a production during the trace.)

5.  The actual LL1Table 

    The rows represent nonterminal symbols, in the order
    specified by the ordinal integers assigned at the top
    of the include file (see 1 above).  The columns 
    represent terminal symbols, in order by their ordinal
    integers.  

    Thus, entry LL1Table[0,0] is the expanding the goal symbol
    nonterminal when facing the first terinal symbol (by ordinal).
    Similarly, LL1Table[2,3] is the entry for the third nonterminal
    (remember, we started ordinals at zero) when facing the 
    fourth terminal symbol (by ordinal).

    The initialization looks quite ugly.  C is particularly bad
    about initialization syntax.

6.  The input stream, represented as ordinals of the words

    The pseudo-scanner in the skeleton parser simply works its 
    way through the Words[] array in order.  The Words[] array
    holds ordinals of the words.  You can use the definitions
    from the start of the file to create this array.

    Presumably, you will edit the Words[] array into the file by hand.