help on reentrant parser in bison

Hari Nair <hnair@msmail.sapient.com>
Sat, 11 Nov 1995 01:26:00 GMT

          From comp.compilers

Related articles
help on reentrant parser in bison hnair@msmail.sapient.com (Hari Nair) (1995-11-11)
Re: help on reentrant parser in bison mats@snake.irf.se (Mats Luspa) (1995-11-14)
| List of all articles for this month |
Newsgroups: comp.compilers
From: Hari Nair <hnair@msmail.sapient.com>
Keywords: yacc, question, comment
Organization: Compilers Central
Date: Sat, 11 Nov 1995 01:26:00 GMT

Hi,


I'm trying to implement a re-entrant (recursive) parser using
%pure_parser in Bison.


for eg; to evaluate an expression a+b+c
          where a=x+y+z
                                        b,c,x,y,c are numbers


                            this expression is evaluated as follows ;
                                        evaluate{evaluate(x+y+z) + b + c}


          where 'evaluate' is a function which parses the expression, and
evaluates it.


this makes it a re-entrant or recursive parser, which cannot be
done with yacc.
          (ie; you cannot call yyparse within another yyparse)


bison was the suggested alternative. i have gone thru its reference
manual (the one and only reference to bison that i could find), but
couldn't figure out the sample code for implementing 'pure_parser'.


the eg. given above is a simple one. the expressions can become
really complex with IF statements, etc.


I was wondering if anybody can help me out in this - any references
or pointers (where to look etc.) would be a real help. I have tried
most of the bookstores around Boston. No luck. If anybody has
implemented this before a code fragment which shows how to use
%union, YYPARSEPARAM, YYLEXPARAM, yyparse, define yylex would be
greatly appreciated.


I have a deadline by next wednesday - so am getting really desperate. please
help !!


Thanks in advance.


Hari Nair


hnair@sapient.com
[I usually compile to intermediate form, then interpret that, so there's no
issue of recursive parsing. If worst comes to worst, hacking the yacc
or byacc parser skeleton to make it reentrant isn't that hard. -John]
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.