help-bison
[Top][All Lists]
Advanced

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

Question on parsing streaming input in Bison/Bison++


From: Sriram Sankar
Subject: Question on parsing streaming input in Bison/Bison++
Date: Wed, 29 Nov 2000 17:08:07 -0800

Hi,
    I have a question on parsing streaming input (asynchronous socket).
I am using Flex (C++ option) and Bison. Now I'll be moving over to
Bison++.
    I'll be getting the data stream through an asynchronous socket.
The current implementation gets all the data and then lex/parse it.
For performance improvement, I'm thinking of parsing blocks of data as
they come in.
    The obvious thought that came to me was to make the Lexer to be
able to handle the data asynchronously. (i.e) Lex all the data and
keep the tokens in a stack and after all the data has been got, invoke
the parser and feed it through the stack.
    But I think it'd be better to parse the data too continously. So,
my next thought was to make 2 lexing functions. The first function
gets the data asynchronously and converts to tokens. It also groups them

as blocks of parsable chunks. The parser is called everytime
a block of parsable chunk is identified. And the parser calls another
lexing
function which just serves the tokens from the parsable chunk. The
parser
would get called as soon as a parsable chunk is found. The
definition of  parsable chunks means a block of data where the lexing
state is at INITIAL at the begining and end of block.
    Can you pl. suggest a better mechanism or pattern to deal with this
problem? Any help is greatly appreciated.
    I'm sure my explanation so far may not be very clear. I'll explain
more
if you need further details.

Thanks,
Sriram

I'll try to give an example :
The data looks like this:


This is all text or <bold>html</bold>
<mytag-begins>
  <myother-tags>
  </myother-tags>
<mytag-ends>
This is more text or html


The above data would get broken into 3 blocks of parsable data.

1) This is all text or <bold>html</bold>
2) <mytag-begins>
      <myother-tags>
      </myother-tags>
   <mytag-ends>
3) This is more text or html

These parts are sent to the parser seperately.






reply via email to

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