-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
peg/match should give a stack trace on errors #1010
Comments
Possibly related: #255 |
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:
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. |
With respect to "original peg debugging script", perhaps @bakpakin meant the bit posted by @andrewchambers initially:
|
FWIW, margaret now supports all PEG specials (including the newer additions like There are a few differences mentioned here, but I doubt those make a big difference in practice. |
There is now a tracing tool of sorts available via here. It's possible it might help in investigating some kinds of situations. |
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: