home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / gnu / utils / bug / 2036 < prev    next >
Encoding:
Text File  |  1992-11-11  |  2.7 KB  |  79 lines

  1. Newsgroups: gnu.utils.bug
  2. Path: sparky!uunet!convex!linac!pacific.mps.ohio-state.edu!cis.ohio-state.edu!aero.org!cal
  3. From: cal@aero.org
  4. Subject: follow-up on questions about multiple parsers and lexers
  5. Message-ID: <199211111914.AA20780@aerospace.aero.org>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: GNUs Not Usenet
  8. Distribution: gnu
  9. Date: Wed, 11 Nov 1992 19:14:40 GMT
  10. Approved: bug-gnu-utils@prep.ai.mit.edu
  11. Lines: 66
  12.  
  13. about a month ago, i asked about using multiple parsers
  14.  
  15. my bug report was for bison version 1.10,
  16. version 1.19 does not have that bug any more
  17.  
  18. the more interesting question was about multiple parsers and lexers -
  19. i received useful information immediately from Kevin Burton and
  20. Kevin Rodgers
  21.  
  22. their hints led me to look for yyrestart,
  23. and then to a newer version of flex that has yyrestart
  24. (version 2.3)
  25.  
  26. ok, here is the problem and the solution (so far) -
  27. i have multiple lexers and multiple parsers in the same address space
  28. (on a sparcstation),
  29. so i need to separate the global symbols they use,
  30. and also each one may be called at several times,
  31. to read a different file each time,
  32. so i need to initialize them appropriately
  33.  
  34. it turns out that 'yyrestart' easily handles the second problem
  35. (though it fails if i call yyrestart before the first call to the parser,
  36. so each of my parsers need to identify the first call,
  37. which is irritating),
  38. but none of the suggestions solves the first one
  39. (it was perhaps not clear that i did not intend to catenate the several files,
  40. but rather to read them as different parses) -
  41.  
  42. i already had include files that define the leftover globals in the parsers
  43. and lexers to different things
  44. (my choice of flex and bison over lex and yacc was exactly because
  45. the gnu programs had made most of the tables static),
  46. but the new version of flex added several more symbols
  47. (having to do with buffers mainly) -
  48.  
  49. these are the interceptions i have so far,
  50. but i needed to look at the generated code to find them
  51.  
  52. /*definitions to intercept flex variable names*/
  53. #define yyin yZZin
  54. #define yyout yZZout
  55. #define yytext yZZtext
  56. #undef YY_DECL
  57. #define YY_DECL yZZlex()
  58. #define yyrestart yZZrestart
  59. #define yy_switch_to_buffer yZZ_switch_to_buffer
  60. #define yy_load_buffer_state yZZ_load_buffer_state
  61. #define yy_create_buffer yZZ_create_buffer
  62. #define yy_delete_buffer yZZ_delete_buffer
  63. #define yy_init_buffer yZZ_init_buffer
  64. /* I don't know why these are external in the generated lexer */
  65. #define yyleng yZZleng
  66. #define yylval yZZlval
  67.  
  68. /*definitions to intercept bison variable names*/
  69. #define yylex ZZlexer
  70. #define yyparse ZZparse
  71. #define yydebug yZZdebug
  72. #define yyerror ZZyyerr
  73. /* I don't know why these are external in the generated parser */
  74. #define yychar yZZchar
  75. #define yylval yZZlval
  76. #define yylloc yZZlloc
  77. #define yynerrs yZZnerrs
  78.  
  79.