You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Working with PEG parsers for the first time. They are very cool (along with the rest of Janet).
However, debugging a failed "peg/match" can be difficult. Although PEG operates with an internal stack, it is not printed out on errors.
Ocassionally I will overflow the stack or encounter some other sort of error deep in matching. It is pretty easily to write left-recursive grammar accidentally. In that case, error: peg/match recursed too deeply is not a particularly helpful error message. 😉
It would be nice to (somehow) track the internal PEG stack and print it on error.
If the performance cost of this is unacceptable, we could keep it behind a debug flag.
Maybe there is some sort of compromise (short of full stack traces) that could track the PEG stack's last three or four positions?
Ideally, this would be the first step toward more tools to debug PEG parsers. An (optional) peg/debug submodule would be awesome.
The text was updated successfully, but these errors were encountered:
In #255, @bakpakin mentioned an "original peg debugging script", but I can't find that anywhere :(
I learned about Margaret after filing this issue, and the debugging tools there look very useful (although I haven't used them a single time).
I think in terms of "peg debugging", there are two options:
Emulate some of the the debugging features (especially stack tracing) in peg.c.
Make Margaret an semi-official tool, using regression tests to keep it in sync
I think option (2) probably looks better. We could have the CI mark any incompatibilities between the two as warnings. That way we won't block development, and we could eventually get around to fixing any incompatibilities.
Working with PEG parsers for the first time. They are very cool (along with the rest of Janet).
However, debugging a failed "peg/match" can be difficult. Although PEG operates with an internal stack, it is not printed out on errors.
Ocassionally I will overflow the stack or encounter some other sort of error deep in matching. It is pretty easily to write left-recursive grammar accidentally. In that case,
error: peg/match recursed too deeply
is not a particularly helpful error message. 😉It would be nice to (somehow) track the internal PEG stack and print it on error.
If the performance cost of this is unacceptable, we could keep it behind a debug flag.
Maybe there is some sort of compromise (short of full stack traces) that could track the PEG stack's last three or four positions?
Ideally, this would be the first step toward more tools to debug PEG parsers. An (optional)
peg/debug
submodule would be awesome.The text was updated successfully, but these errors were encountered: