Open MatthieuDartiailh opened 1 year ago
In the past we have made the generator (in C) output a stack VM:
https://github.com/pablogsal/cpython/tree/pegenvm-2
But that was made for performance and it didn't convince us because debugging it was very hard and performance was basically the same as recursion.
In Python it would allow to workaround recursion but I agree it is no fun to debug. Guess I would have to re-write my parser in something else than Python... Thanks @pablogsal
In enaml (https://github.com/nucleic/enaml), one user reported an error stemming from a recursion error when trying to parse a deeply nested function (see below). The only solution I could think of would for pegen to make use of the trampoline pattern to avoid recursion through the use of generators. However, such a change would be highly invasive and would make the code harder to reason about.
Does anybody has an alternative option to suggest ?