« Return to Thread: Parsing progressively...

Re: Parsing progressively...

by Hartmut Kaiser :: Rate this Message:

Reply to Author | View in Thread

I think you're mixing two things here (see below).

> Just a quick question about spirit. If I was to use it to create and
> parse xml content, will it parse of the content continuously or could
> one build up a SAX like parser with this framework. Something akin to
> xecedes pparse or libxml parse_chunk.

This is certainly possible. Use semantic actions. These get called whenever
something matching your grammar has been seen in the input. See the
quickbook tool as a nice example how this can be used in practice.

> More detail:
> I am storing data from the network in a boost::array and I have written
> a forward iterator to decode via dereferencing each utf8 byte sequence
> into its unicode code point. Should I build up the passed content into
> another buffer so that spirit could parse from "<"....">" or could I
> pass the original boost array that will contain the "<" and then later
> another parse call to get the ">" in the next iteration of the network
> loop. Will spirit then recognize the start tag over the buffer break?
>
> (does spirit keep its own buffer to track the parse with its state
> machine?)

This is not possible as Spirits recursive descent parser framework stores
the current parser state on the (hardware-) stack. In order to do the
context switch in between two parse steps you need to use some co-routine
library. But this is non-trivial and requires some changes to Spirit itself.

Regards Hartmut




------------------------------------------------------------------------------
_______________________________________________
Spirit-general mailing list
Spirit-general@...
https://lists.sourceforge.net/lists/listinfo/spirit-general

 « Return to Thread: Parsing progressively...