Merge pull request #141 from pesco/iterative
Iterative (chunked) input processing
This commit is contained in:
commit
cb93c3b4ec
11 changed files with 668 additions and 80 deletions
|
|
@ -349,6 +349,7 @@ void *h_stringmap_get(const HStringMap *m, const uint8_t *str, size_t n, bool en
|
|||
return m->epsilon_branch;
|
||||
}
|
||||
|
||||
// A NULL result means no parse. NEED_INPUT means lookahead is too short.
|
||||
void *h_stringmap_get_lookahead(const HStringMap *m, HInputStream lookahead)
|
||||
{
|
||||
while(m) {
|
||||
|
|
@ -362,9 +363,13 @@ void *h_stringmap_get_lookahead(const HStringMap *m, HInputStream lookahead)
|
|||
// reading bits from it does not consume them from the real input.
|
||||
uint8_t c = h_read_bits(&lookahead, 8, false);
|
||||
|
||||
if (lookahead.overrun) { // end of input
|
||||
// XXX assumption of byte-wise grammar and input
|
||||
return m->end_branch;
|
||||
if (lookahead.overrun) { // end of chunk
|
||||
if (lookahead.last_chunk) { // end of input
|
||||
// XXX assumption of byte-wise grammar and input
|
||||
return m->end_branch;
|
||||
} else {
|
||||
return NEED_INPUT;
|
||||
}
|
||||
}
|
||||
|
||||
// no match yet, descend
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue