-
PEGTL allows to parse data by chunks (partial input) but it's only possible when parser drives the input, i.e. doing active reads when it needs more data to parse. It works fine for files but consider HTTP or similar when data comes from a socket and we can't do blocking read of that socket. Instead we can only read some chunks of data when it's received and pass a chunk to the parser. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
The state of the parser consists of the State arguments and the current call stack with all of its automatic variables. This makes it rather impossible to return from a partial parsing run so that it can be resumed later. The classical way to achieve this kind of producer-consumer coupling is with coroutines (or with proper continuations, if available, which of course make everything easy). As soon as C++20 coroutines are fully functional in GCC or Clang I'll check them out in detail and hopefully they'll allow us to put something together. |
Beta Was this translation helpful? Give feedback.
-
Thanks, Colin. I expected major problems but thought it might be possible to identify (even with help of a user, e.g. like in Lua with yield but it supports couroutines natively) some points where state could be collapsed to a managable size. But if everything is hold on stack then no way of course... |
Beta Was this translation helpful? Give feedback.
-
I'm very much looking forward to my compiler implementing standard coroutines, and this will be the first thing I'll use them for. |
Beta Was this translation helpful? Give feedback.
The state of the parser consists of the State arguments and the current call stack with all of its automatic variables. This makes it rather impossible to return from a partial parsing run so that it can be resumed later. The classical way to achieve this kind of producer-consumer coupling is with coroutines (or with proper continuations, if available, which of course make everything easy). As soon as C++20 coroutines are fully functional in GCC or Clang I'll check them out in detail and hopefully they'll allow us to put something together.