help-bison
[Top][All Lists]
Advanced

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

Parsing from continuous stream


From: Daniel Kraft
Subject: Parsing from continuous stream
Date: Sat, 19 Jan 2008 17:33:32 +0000
User-agent: Thunderbird 2.0.0.0 (X11/20070425)

Hi,

I'm trying to use GNU bison to parse from a "continuous" stream, that is, I do want to implement a program similar to a shell: parse one "command" at a time, process it, and continue until end-of-stream is encountered.

However, I do want my parser to return the parsed tree to the calling program to process it on each step, so ideally I'd like bison to return from yyparse() when a complete instance of the start symbol is read, but it seems it does not do this (waits for special 0-token, as far as I found out)--to counter-act, I currently do something like this:

start_symbol:
  real_start_symbol
  {
    storeValueForProcession($1);
    YYACCEPT;
  }
;

This works, except that the YYACCEPT seems to discard the current look-ahead-token if some has been read, meaning it is missing from the input when parsing the next step.

I'm aware that I could do the processing right inside the bison action instread of returning the token value, but this is something I'd like to avoid because it does not fit in well with my current design. Is there some way I can make bison return whenever the start-symbol is successfully reduced and keep its stack and the like so I can continue parsing the next instance of it with the next call to yyparse()?

Thank you very much,
Daniel

--
Got two Dear-Daniel-Instant Messages
by MSN, associate ICQ with stress--so
please use good, old E-MAIL!




reply via email to

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