lua-users home
lua-l archive

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

On 1/16/19 11:16 AM, pocomane wrote:
> I have a working parser that acts on a single string, but now I would
> like to extend it to get the input splitted among several chunks,
> without waiting for the whole data unless it is necessary.
> We consider, for example, the pattern
> ^{%a+}
> to match against the following input:
> {foobar}
> We suppose it is splitted in two chunks right in the middle.
> On the first chunk the match fails. But it may match if I wait for
> another chunk. How I can check for this? [1]

I think you need to implement finite state automata if
you need to know parsing state at any character of input.

Alternatively, you may limit maximum size of "valid" caption.
Say, to 8K. And then implement sliding window buffer of that
size with stock pattern matching.

-- Martin