help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

tail recursion


From: OGLHacker
Subject: tail recursion
Date: Sun, 15 Sep 2002 21:52:59 -0400

Hello,

I've been fooling around with flex and bison for a while now, and I'm currently 
trying to put together a VRML file parser.  I want it to create and initialize 
C++ objects in a scene graph, so the parser needs to understand C++.

My problems started when I began to read in non-trivial files and I encountered 
a parser stack overflow.  The problem seems to have two parts.

First, I discovered that the stack depth was not being updated in accordance 
with the YYMAXDEPTH constant.  I'm not sure, but it looks like YYSTACK_RELOCATE 
does not get #define'd if C++ is used.  Does this mean I need to define my own 
yyoverflow() method?  If so, how do I do that?  I looked everywhere for 
documentation and can't find any.  This problem is not TOO serious, though, in 
that I can redifine YYINITDEPTH to cover it. 

But ...

The more serious problem is with right recursion in the syntactical definitions 
of the grammar.  I want to parse a list of vertices that could be arbitrarily 
long (depending on the file used for input).  The production is typical:

       vertex_list : vertex ',' vertex_list ;

No matter how big I make the stack, some file will eventually make it overflow. 
 I'm thinking (hoping) that there may be some routine means of overcoming the 
tail recursion.  I know I'm not the first person to encounter it :)  I've tried 
everthing I can think of, including consulting the dragon book.  If there's a 
way, and you know what it is, please share it with me.

Thanks for your help,

Graham

__________________________________________________________________
The NEW Netscape 7.0 browser is now available. Upgrade now! 
http://channels.netscape.com/ns/browsers/download.jsp 

Get your own FREE, personal Netscape Mail account today at 
http://webmail.netscape.com/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]