home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************/
- /* yacc.hak */
- /* Guide to yacc internals. */
- /************************************************************************/
-
-
- /************************************************************************/
- /* contents */
- /* */
- /* code outline */
- /* source files */
- /* data structures */
- /* algorithms */
- /* */
- /************************************************************************/
-
- /************************************************************************/
- /* history */
- /* */
- /* 85Nov12 CrT Created. */
- /* */
- /* */
- /* credits */
- /* CrT=CrT */
- /* */
- /************************************************************************/
-
-
-
- /************************************************************************/
- /* code outline */
- /************************************************************************/
-
- main
- y2Initialize
- y2Define
- y2yyParse
- y2GetToken
- y2WriteDefines
- y2CpyCode
- y2CpyUnion
- y2FindName
- y2CpyAction
- y1Yield
- y1CheckEmpty
- y1First
- y1SetUnion
- y1Lookahead
- y1PrintLookahead
- y1MakeStates
- y1PutItem
- y1Closure
- y3PackState
- y3PutStates
- y1SetUnion
- y3Gotos
- y3HideProductions
- y1Summary
- y4Optimize
- y4GetNumber
- y4NextI
- y4StoreState
- y4EnterGoto
- y4PutParser
- y1PutRest
-
-
-
- /************************************************************************/
- /* source files */
- /************************************************************************/
-
- system.h Master configuration file.
- dtXtrn.h Global constants and variables.
-
- y1.c Main program, basic parser construction.
- y2.c Input routines -- parser, scanner.
- y3.c Output routines.
- y4.c Parser optimizer.
-
- Most problems can probably be handled by modifying system.h, which
- declares arrays sizes and file names.
-
-
-
- /************************************************************************/
- /* data structures */
- /************************************************************************/
-
- y2.c contains the symbol tables. Names are packed sequentially
- into y2Text[], with various arrays serving as indices into it. Lookup
- is by a simple linear search -- remarkable considering the evident efforts
- to make the low-level loops run quickly. Grammar rules are packed
- sequentially into y2Pool[], again variously indexed. y2.c has a more
- detailed description of all this.
-
-
-
- /************************************************************************/
- /* algorithms */
- /************************************************************************/
-
- In general, yacc follows the standard Un*x hack-to-size, bash-to-fit
- programming methodology. Symbol tables are unsorted, allocation is
- static, algorithms are naive. Evidently elegance is not everything:
- the Gauls sacked Rome, and Un*x is a roaring success.
-
- Yacc input is segmented into tokens using an ad hoc scanner, then parsed
- by ad hoc recursive-decent code with embedded actions entering information
- into the symbol tables. User-supplied actions are processed as they are
- parsed and written into a temporary file.
-
-
-
-