home *** CD-ROM | disk | FTP | other *** search
- /*
- * 12-Apr-83 (RBD) Add symbolic exit status
- * 4-Dec-89 (MvL) include impure section in MAIN.
- * 26-Apr-91 (AE) Moved part of data to YDATA because of segment overflow
- * for HUGETAB configuration of YACC.
- */
-
- # include <stdlib.h>
- # define y1imp yes
- # define y2imp YES
- # define y3imp YES
- # include "dtxtrn.h"
-
- /* lookahead computations */
-
- int tbitset; /* size of lookahead sets */
- struct looksets lkst[ LSETSIZE ];
- int nlset = 0; /* next lookahead set index */
- int nolook = 0; /* flag to suppress lookahead computations */
- struct looksets clset; /* temporary storage for lookahead computations */
-
- /* working set computations */
-
- struct wset wsets[ WSETSIZE ];
- struct wset * cwp;
-
- /* state information */
-
- int nstate = 0; /* number of states */
- struct item * pstate[ NSTATES + 2 ]; /* pointers to the descriptions of the states */
- int tystate[ NSTATES ]; /* contains type information about the states */
- int indgo[ NSTATES ]; /* index to the stored goto table */
- int tstates[ NTERMS ]; /* states generated by terminal gotos */
- int ntstates[ NNONTERM ]; /* states generated by nonterminal gotos */
- int mstates[ NSTATES ]; /* chain of overflows of term/nonterm generation lists */
-
- /* other storage areas */
-
- int temp1[ TEMPSIZE ]; /* temporary storage, indexed by terms + ntokens or states */
- int lineno = 1; /* current input line number */
- int fatfl = 1; /* if on, error is fatal */
- int nerrors = 0; /* number of errors */
-
- /* storage for information about the nonterminals */
-
- int * * pres[ NNONTERM + 2 ]; /* vector of pointers to productions yielding each nonterminal */
- struct looksets * pfirst[ NNONTERM + 2 ]; /* vector of pointers to first sets for each nonterminal */
- int pempty[ NNONTERM + 1 ]; /* vector of nonterminals nontrivially deriving e */
-
- /* data pulled from internal static to here */
- /* declared external only in user module */
-
- int * pyield[ NPROD ]; /* from ycpres */
- char sarr[ ISIZE ]; /* from ywritm */
- /* communication variables between various I/O routines */
-
- char * infile; /* input file name */
- int numbval; /* value of an input number */
- char tokname[ NAMESIZE ]; /* input token name */
-
- /* storage of names */
-
- char cnames[ CNAMSZ ]; /* place where token and nonterminal names are stored */
- int cnamsz = CNAMSZ; /* size of cnames */
- char * cnamp = cnames; /* place where next name is to be put in */
- int ndefout = 3; /* number of defined symbols output */
-
- /* storage of types */
- int ntypes; /* number of types defined */
- char * typeset[ NTYPES ]; /* pointers to type tags */
-
- /* symbol tables for tokens and nonterminals */
-
- int ntokens = 0;
- struct toksymb tokset[ NTERMS ];
- int toklev[ NTERMS ];
- int nnonter = -1;
- struct ntsymb nontrst[ NNONTERM ];
- int start; /* start symbol */
-
- /* assigned token type values */
- int extval = 0;
-
- /* input and output file descriptors */
-
- FILE * finput; /* yacc input file */
- FILE * faction; /* file for saving actions */
- FILE * fdefine; /* file for # defines */
- FILE * ftable; /* y.tab.c file */
- FILE * ftemp; /* tempfile to pass 2 */
- FILE * foutput; /* y.output file */
-
- main( argc, argv )
- int argc;
- char * argv[ ];
-
- {
-
- puts( "Setup..." );
- setup( argc, argv ); /* initialize and read productions */
- puts( "cpres ..." );
- tbitset = NWORDS( ntokens );
- cpres( ); /* make table of which productions yield a given nonterminal */
- puts( "cempty ..." );
- cempty( ); /* make a table of which nonterminals can match the empty string */
- puts( "cpfir ..." );
- cpfir( ); /* make a table of firsts of nonterminals */
- puts( "stagen ..." );
- stagen( ); /* generate the states */
- puts( "output ..." );
- output( ); /* write the states and the tables */
- puts( "go2out ..." );
- go2out( );
- puts( "hideprod ..." );
- hideprod( );
- puts( "summary ..." );
- summary( );
- puts( "callopt ..." );
- callopt( );
- puts( "others ..." );
- others( );
- puts( "DONE !!!" );
- return ( EX_SUC );
- }
-
-