🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.misc.discuss
Article #73715

flex/bison

#73715
From: Jim Ertle
Date: Thu, 25 Jul 1991 17:38
43 lines
2483 bytes
Hi!
   I'm trying to write a pure (re-entrant) parser using flex and
bison.  In the bison manual, it tells me I can use '%pure_parser' to
do this, and I also need to redeclare yylex like this:

    yylex(lvalp, llocp)
        YYSTYPE *lvalp;
	YYLTYPE *llocp;

    This is so bison doesn't have to use the global variables that it
normally uses to get info from yylex.

    The flex documents tell me that I can re-declare yylex in this
manner if I use :

    #define YY_DECL int yylex(lvalp, llocp) YYSTYPE *lvalp; YYLTYPE *llocp;

    My problem is that yylex doesn't appear to know what YYLTYPE is.
Is this the starndard way to make a re-entrant parser using flex and
bison, or is it only used when you are writing your own parser?
    I figured that this would work by overshadowing the global
declarations of lvalp and llocp with these local ones.  However, when
I searched lex.yy.c, I found no declarations of lvalp or llocp.
Neither did I find declarations for the global variables that bison
says it uses, yylval and yylloc.  I even looked for an include file
that either might use that defines either of these, and I can't find it.
    I'm thinking that I might be able to overcome my problems if I
changed YY_INPUT so that it only reads one character at a time.  This
might solve my problem, as I am implementing an interpreter that
changes input files, and I find that there is stuff from the first
file still in the buffer when I change to the second file.  In a truly
re-entrant parser, this wouldn't be a problem, would it?
    The flex document also suggests that lex might be a better choice
for a re-entrant parser.
    Any suggestions?



--
===============================================================================
James A. Ertle, University of Vermont, Burington, Vermont, USA
send mail to: ertle@kira.uvm.edu
===============================================================================
Technical Details
Message-ID: <ertle.680463521@kira>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!kira!ertle

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1025b4,a35e4a95d29d654d,start
X-Google-Attributes: gid1025b4,public
X-Google-ArrivalTime: 1991-07-25 15:15:23 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!kira!ertle
From: ertle@kira.uvm.edu (Jim Ertle)
Newsgroups: gnu.misc.discuss
Subject: flex/bison
Message-ID: <ertle.680463521@kira>
Date: 25 Jul 91 17:38:41 GMT
Sender: news@uvm.edu
Distribution: gnu.misc/discuss
Organization: Univ. of Vermont, Eng., Math., and Bus. Admin. (EMBA) Computer Facility
Lines: 43