home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: gnu.utils.bug
- Path: sparky!uunet!convex!linac!pacific.mps.ohio-state.edu!cis.ohio-state.edu!aero.org!cal
- From: cal@aero.org
- Subject: follow-up on questions about multiple parsers and lexers
- Message-ID: <199211111914.AA20780@aerospace.aero.org>
- Sender: gnulists@ai.mit.edu
- Organization: GNUs Not Usenet
- Distribution: gnu
- Date: Wed, 11 Nov 1992 19:14:40 GMT
- Approved: bug-gnu-utils@prep.ai.mit.edu
- Lines: 66
-
- about a month ago, i asked about using multiple parsers
-
- my bug report was for bison version 1.10,
- version 1.19 does not have that bug any more
-
- the more interesting question was about multiple parsers and lexers -
- i received useful information immediately from Kevin Burton and
- Kevin Rodgers
-
- their hints led me to look for yyrestart,
- and then to a newer version of flex that has yyrestart
- (version 2.3)
-
- ok, here is the problem and the solution (so far) -
- i have multiple lexers and multiple parsers in the same address space
- (on a sparcstation),
- so i need to separate the global symbols they use,
- and also each one may be called at several times,
- to read a different file each time,
- so i need to initialize them appropriately
-
- it turns out that 'yyrestart' easily handles the second problem
- (though it fails if i call yyrestart before the first call to the parser,
- so each of my parsers need to identify the first call,
- which is irritating),
- but none of the suggestions solves the first one
- (it was perhaps not clear that i did not intend to catenate the several files,
- but rather to read them as different parses) -
-
- i already had include files that define the leftover globals in the parsers
- and lexers to different things
- (my choice of flex and bison over lex and yacc was exactly because
- the gnu programs had made most of the tables static),
- but the new version of flex added several more symbols
- (having to do with buffers mainly) -
-
- these are the interceptions i have so far,
- but i needed to look at the generated code to find them
-
- /*definitions to intercept flex variable names*/
- #define yyin yZZin
- #define yyout yZZout
- #define yytext yZZtext
- #undef YY_DECL
- #define YY_DECL yZZlex()
- #define yyrestart yZZrestart
- #define yy_switch_to_buffer yZZ_switch_to_buffer
- #define yy_load_buffer_state yZZ_load_buffer_state
- #define yy_create_buffer yZZ_create_buffer
- #define yy_delete_buffer yZZ_delete_buffer
- #define yy_init_buffer yZZ_init_buffer
- /* I don't know why these are external in the generated lexer */
- #define yyleng yZZleng
- #define yylval yZZlval
-
- /*definitions to intercept bison variable names*/
- #define yylex ZZlexer
- #define yyparse ZZparse
- #define yydebug yZZdebug
- #define yyerror ZZyyerr
- /* I don't know why these are external in the generated parser */
- #define yychar yZZchar
- #define yylval yZZlval
- #define yylloc yZZlloc
- #define yynerrs yZZnerrs
-
-