home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / compcomp / yacc / yacc.hak < prev    next >
Encoding:
Text File  |  1980-01-01  |  3.8 KB  |  115 lines

  1. /************************************************************************/
  2. /*                yacc.hak                */
  3. /*  Guide to yacc internals.                        */
  4. /************************************************************************/  
  5.  
  6.  
  7. /************************************************************************/ 
  8. /*                              contents                                */   
  9. /*                                                                      */   
  10. /*    code outline                            */
  11. /*    source files                            */
  12. /*    data structures                         */
  13. /*    algorithms                            */
  14. /*                                    */
  15. /************************************************************************/
  16.    
  17. /************************************************************************/  
  18. /*                              history                                 */  
  19. /*                                                                      */  
  20. /* 85Nov12 CrT    Created.                        */
  21. /*                                                                      */
  22. /*                                    */
  23. /*                credits                 */
  24. /*      CrT=CrT                                                         */
  25. /*                                    */
  26. /************************************************************************/
  27.  
  28.  
  29.  
  30. /************************************************************************/  
  31. /*                              code outline                            */   
  32. /************************************************************************/   
  33.  
  34. main
  35.     y2Initialize
  36.         y2Define
  37.         y2yyParse 
  38.             y2GetToken
  39.             y2WriteDefines 
  40.             y2CpyCode 
  41.             y2CpyUnion 
  42.             y2FindName 
  43.             y2CpyAction 
  44.     y1Yield
  45.     y1CheckEmpty
  46.     y1First
  47.     y1SetUnion
  48.     y1Lookahead
  49.     y1PrintLookahead
  50.     y1MakeStates
  51.     y1PutItem
  52.     y1Closure
  53.     y3PackState
  54.     y3PutStates
  55.     y1SetUnion
  56.     y3Gotos
  57.     y3HideProductions
  58.     y1Summary
  59.     y4Optimize
  60.     y4GetNumber
  61.     y4NextI
  62.     y4StoreState
  63.     y4EnterGoto
  64.     y4PutParser
  65.     y1PutRest
  66.  
  67.  
  68.  
  69. /************************************************************************/  
  70. /*                source files                */
  71. /************************************************************************/  
  72.  
  73. system.h    Master configuration file.
  74. dtXtrn.h    Global constants and variables.
  75.  
  76. y1.c        Main program, basic parser construction.
  77. y2.c        Input routines -- parser, scanner.
  78. y3.c        Output routines.
  79. y4.c        Parser optimizer.
  80.  
  81. Most problems can probably be handled by modifying system.h, which
  82. declares arrays sizes and file names.
  83.  
  84.  
  85.  
  86. /************************************************************************/  
  87. /*                              data structures                         */ 
  88. /************************************************************************/    
  89.   
  90. y2.c contains the symbol tables.  Names are packed sequentially
  91. into y2Text[], with various arrays serving as indices into it.    Lookup
  92. is by a simple linear search -- remarkable considering the evident efforts
  93. to make the low-level loops run quickly.  Grammar rules are packed
  94. sequentially into y2Pool[], again variously indexed.  y2.c has a more
  95. detailed description of all this.
  96.  
  97.  
  98.  
  99. /************************************************************************/  
  100. /*                algorithms                */
  101. /************************************************************************/    
  102.   
  103. In general, yacc follows the standard Un*x hack-to-size, bash-to-fit
  104. programming methodology.  Symbol tables are unsorted, allocation is
  105. static, algorithms are naive.  Evidently elegance is not everything:
  106. the Gauls sacked Rome, and Un*x is a roaring success.
  107.  
  108. Yacc input is segmented into tokens using an ad hoc scanner, then parsed
  109. by ad hoc recursive-decent code with embedded actions entering information
  110. into the symbol tables.  User-supplied actions are processed as they are
  111. parsed and written into a temporary file.
  112.  
  113.  
  114.  
  115.