Incremental Parsing in Nelua #143
Replies: 3 comments 4 replies
-
Seems like it's possible and just got published 😄 https://github.com/zyedidia/gpeg#publications I have just downloaded the publication and thesis of this user to study it carefully; they based their research on LPeg which is quite fascinating! |
Beta Was this translation helpful? Give feedback.
-
The way I typically use LPeg or LPegLabel usually has to parse everything again on every change, and I don't think incremental parsing is feasible with it. On the other hand, LPegLabel supports error recovery, one feature mentioned in that talk. But in Nelua error recovery is not used, the Nelua parser will usually stop on first syntax error and then ignore the renaming code to parse, but this is just a design decision, the only benefit of recovering from errors would be to give extra syntax errors. I've chosen to fail on the first error for the Nelua compiler, to make it simple.
Probably the terminology you are looking for is incremental compiling or incremental parsing.
In the Nelua compiler not much, the compiler does not spend much time parsing, it spends more time analyzing. But incremental parsing makes sense in text editors, because you usually want your syntax highlighted instantaneously.
Worth mentioning that there is a tree sitter parser for Nelua in https://github.com/codehz/tree-sitter-nelua |
Beta Was this translation helpful? Give feedback.
-
By the way, nelua-lang/lualib/nelua/runner.lua Line 42 in b6b67e6 could be replaced with |
Beta Was this translation helpful? Give feedback.
-
I watched "Tree-sitter - a new parsing system for programming tools" by Max Brunsfeld and what fascinated me the most is Incremental Parsing.
That is exactly what I have had in mind for Nelua while I shared my thoughts on Discord, but didn't know the proper terminology to use.
Does LPegRex or LPeg / LPegLabel support such mechanism?
It could improve the coding experience exponentially, because the parsing would be validated during typing in real-time.
Beta Was this translation helpful? Give feedback.
All reactions