On Wed, Aug 30, 2023, at 5:48 AM, Richard wrote:
> Hi,
>
> So the symbols parser is an example of a dynamic parser in X3.  I am trying to
> write a parser for a GIF image file.  A GIF file is a series of chunks.  
> Chunks
> are prefixed with a length indicating the number of bytes in the chunk.  Many
> binary formats have the length of a binary block encoded in the stream 
> followed
> by <length> bytes (or words or whatever unit) representing the block.
>
> How do we parse this using X3 spirit?

I did a dynamic repeat parser back when: 
https://stackoverflow.com/questions/33624149/boost-spirit-x3-cannot-compile-repeat-directive-with-variable-factor/33627991#33627991

>
> Do we use a success handler for the length to record it in the context and 
> then
> somehow use a repeat parser that grabs the repeat count from the context?
> What, exactly, does that look like?

That's a variation. In reality, I'd probably make a parser type - I think it 
was discussed in the comments there too 
https://stackoverflow.com/questions/33624149/boost-spirit-x3-cannot-compile-repeat-directive-with-variable-factor/33627991#comment55039410_33624149

>
> I'm hoping to figure this out in time for a presentation on X3 to Utah C++
> Programmers on Sept. 13th.

Apropos of nothing, there's a building block to get /anything/ lazily parsed: 
https://stackoverflow.com/questions/60171119/boost-spirit-x3-lazy-parser/60176802#60176802

Good luck with the presentation, and have fun!
Seth


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

Reply via email to