Streaming input

128 views
Skip to first unread message

Kannan Goundan

unread,
May 14, 2014, 6:33:09 AM5/14/14
to parboil...@googlegroups.com
Is there a way to make Parboiled2 run on streaming input?

Mathias Doenitz

unread,
May 14, 2014, 7:44:24 AM5/14/14
to parboil...@googlegroups.com
Kannan,

not readily.
The problem is that PEG parsers can potentially backtrack all the way to the beginning of the input.
Therefore you’d have to buffer the stream in its entirety which is probably not what you want.

However, if you have a grammar for streaming input you normally have some kind of “chunks” that form natural backtracking boundaries, i.e. you can ensure (through the grammar design) that the parser would never have to backtrack beyond a chunk boundary.
In these cases you could simply start buffering the stream at a chunk start and let parboiled run against the input with a parser that will only parse one single chunk.
Then, when you have successfully parsed a chunk, you clear the buffer and start the next chunk with a new parser instance.

Would something like that work in your case?

Cheers,
Mathias

---
mat...@parboiled.org
http://www.parboiled.org

On 14 May 2014, at 12:33, Kannan Goundan <kan...@cakoose.com> wrote:

> Is there a way to make Parboiled2 run on streaming input?
>
> --
> You received this message because you are subscribed to the Google Groups "parboiled2.org User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to parboiled-use...@googlegroups.com.
> Visit this group at http://groups.google.com/group/parboiled-user.
> To view this discussion on the web visit https://groups.google.com/d/msgid/parboiled-user/7155d657-fdc6-4a4b-8dd5-150727dc4491%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages