home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 2 / crawlyvol2.bin / program / c / yaccsrc2 / ymain.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-05-19  |  4.8 KB  |  126 lines

  1. /*
  2.  * 12-Apr-83 (RBD) Add symbolic exit status
  3.  *  4-Dec-89 (MvL) include impure section in MAIN.
  4.  * 26-Apr-91 (AE)  Moved part of data to YDATA because of segment overflow
  5.  *                 for HUGETAB configuration of YACC.
  6.  */
  7.  
  8. # include <stdlib.h> 
  9. # define y1imp yes
  10. # define y2imp YES
  11. # define y3imp YES
  12. # include "dtxtrn.h" 
  13.  
  14. /* lookahead computations */
  15.  
  16. int               tbitset;                /* size of lookahead sets */
  17. struct looksets   lkst[ LSETSIZE ];
  18. int               nlset   = 0;      /* next lookahead set index */
  19. int               nolook  = 0;      /* flag to suppress lookahead computations */
  20. struct looksets   clset;                  /* temporary storage for lookahead computations */
  21.  
  22. /* working set computations */
  23.  
  24. struct wset       wsets[ WSETSIZE ];
  25. struct wset     * cwp;
  26.  
  27. /* state information */
  28.  
  29. int               nstate  = 0;      /* number of states */
  30. struct item     * pstate[ NSTATES + 2 ];  /* pointers to the descriptions of the states */
  31. int               tystate[ NSTATES ];     /* contains type information about the states */
  32. int               indgo[ NSTATES ];       /* index to the stored goto table */
  33. int               tstates[ NTERMS ];      /* states generated by terminal gotos */
  34. int               ntstates[ NNONTERM ];   /* states generated by nonterminal gotos */
  35. int               mstates[ NSTATES ];     /* chain of overflows of term/nonterm generation lists  */
  36.  
  37. /* other storage areas */
  38.  
  39. int               temp1[ TEMPSIZE ];      /* temporary storage, indexed by terms + ntokens or states */
  40. int               lineno  = 1;      /* current input line number */
  41. int               fatfl   = 1;      /* if on, error is fatal */
  42. int               nerrors = 0;      /* number of errors */
  43.  
  44. /* storage for information about the nonterminals */
  45.  
  46. int           * * pres[ NNONTERM + 2 ];   /* vector of pointers to productions yielding each nonterminal */
  47. struct looksets * pfirst[ NNONTERM + 2 ]; /* vector of pointers to first sets for each nonterminal */
  48. int               pempty[ NNONTERM + 1 ]; /* vector of nonterminals nontrivially deriving e */
  49.  
  50. /* data pulled from internal static to here */
  51. /* declared external only in user module    */
  52.  
  53. int             * pyield[ NPROD ];        /* from ycpres */
  54. char              sarr[ ISIZE ];          /* from ywritm */
  55. /* communication variables between various I/O routines */
  56.  
  57. char            * infile;                 /* input file name */
  58. int               numbval;                /* value of an input number */
  59. char              tokname[ NAMESIZE ];    /* input token name */
  60.  
  61. /* storage of names */
  62.  
  63. char              cnames[ CNAMSZ ];       /* place where token and nonterminal names are stored */
  64. int               cnamsz  = CNAMSZ; /* size of cnames */
  65. char            * cnamp   = cnames; /* place where next name is to be put in */
  66. int               ndefout = 3;      /* number of defined symbols output */
  67.  
  68. /* storage of types */
  69. int               ntypes;                 /* number of types defined */
  70. char            * typeset[ NTYPES ];      /* pointers to type tags */
  71.  
  72. /* symbol tables for tokens and nonterminals */
  73.  
  74. int               ntokens = 0;
  75. struct toksymb    tokset[ NTERMS ];
  76. int               toklev[ NTERMS ];
  77. int               nnonter = -1;
  78. struct ntsymb     nontrst[ NNONTERM ];
  79. int               start;                  /* start symbol */
  80.  
  81. /* assigned token type values */
  82. int               extval  = 0;
  83.  
  84. /* input and output file descriptors */
  85.  
  86. FILE            * finput;                 /* yacc input file */
  87. FILE            * faction;                /* file for saving actions */
  88. FILE            * fdefine;                /* file for # defines */
  89. FILE            * ftable;                 /* y.tab.c file */
  90. FILE            * ftemp;                  /* tempfile to pass 2 */
  91. FILE            * foutput;                /* y.output file */
  92.  
  93. main( argc, argv )
  94. int    argc;
  95. char * argv[ ];
  96.  
  97. {
  98.  
  99.   puts( "Setup..." );
  100.   setup( argc, argv ); /* initialize and read productions */
  101.   puts( "cpres ..." );
  102.   tbitset = NWORDS( ntokens );
  103.   cpres( );            /* make table of which productions yield a given nonterminal */
  104.   puts( "cempty ..." );
  105.   cempty( );           /* make a table of which nonterminals can match the empty string */
  106.   puts( "cpfir ..." );
  107.   cpfir( );            /* make a table of firsts of nonterminals */
  108.   puts( "stagen ..." );
  109.   stagen( );           /* generate the states */
  110.   puts( "output ..." );
  111.   output( );           /* write the states and the tables */
  112.   puts( "go2out ..." );
  113.   go2out( );
  114.   puts( "hideprod ..." );
  115.   hideprod( );
  116.   puts( "summary ..." );
  117.   summary( );
  118.   puts( "callopt ..." );
  119.   callopt( );
  120.   puts( "others ..." );
  121.   others( );
  122.   puts( "DONE !!!" );
  123.   return ( EX_SUC );
  124. }
  125.  
  126.