fstirlitz / luaparse

A Lua parser written in JavaScript
https://fstirlitz.github.io/luaparse/
MIT License
459 stars 91 forks source link

Streaming parser #81

Open fstirlitz opened 4 years ago

fstirlitz commented 4 years ago

Right now this parser can only generate an AST when the entire input has been put in a single string value; only lexing seems to be possible in a streaming manner (although I have not tested if it works reliably). It would be useful to have a streaming parser which can process a Lua script without holding it in memory in its entirety.

If this feature is added, it will definitely only going to be in a major, backwards-incompatible release. I dare even say that this is the kind of feature for the sake of which I might drop my curmudgeonly attitude towards new language features, because a natural way to achieve it would be via asynchronous generators, only available since ECMA-262 9th Ed.; there's no way I'd be dealing with the callback extra-hell that would otherwise result.