Skip to content
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

Added initial debugger implementation. #277

Closed
wants to merge 4 commits into from
Closed

Added initial debugger implementation. #277

wants to merge 4 commits into from

Conversation

dragostis
Copy link
Contributor

Fixes #98.

This implementation is quite rudimentary:

  • relies on threads instead of stack-full generators
  • parsing threads that have not reached their end-of-input will not be joined
  • commands parsing is rough and brittle; e.g. it doesn't support paths that contain white space
  • the readline's formatting could use some improvement
  • only shows position from the ParserState when it reaches a breakpoint
  • no way to run another rule from a breakpoint, only from the start

I'm not completely convinced that we should merge this. But I think it makes for a decent proof-of-concept. Maybe someone would be interested in further work here? @hansihe, this should be good enough as-is for tracing 2.0 grammars.

@hansihe
Copy link

hansihe commented Sep 16, 2018

Thanks, this certainly helps a lot! I'm just going to braindump some more ideas I have

  • It would be nice if it could be made to spit out every single rule it enters. Even though this produces a huge amount of output, it's often very useful for finding the right starting point for further investigation.
  • For both automation and quickly rerunning commands it would be nice if the point above, along with just general breakpoint debugging could be started directly from the command line. I could imagine something like this pest_debugger run --rule top --grammar grammar.pest --input indata.txt --breakpoint number --breakpoint digit. It could then drop you into the interactive shell when it hits a breakpoint. This makes it easy to run things repeatedly, and shortens the debug feedback loop.

I also hit #279, which might be related to the debugger.

@dragostis
Copy link
Contributor Author

By the way, if you need these improvements soon, you could fork my own PR and work on a separate PR. I'm happy to close this one in favor of that.

@hansihe
Copy link

hansihe commented Sep 17, 2018

Yep, I was planning on doing that, but last week was quite busy for me. Hoping to work on something this week.

@dragostis
Copy link
Contributor Author

@hansihe, any news regarding your progress?

tomtau pushed a commit to tomtau/pest that referenced this pull request Nov 20, 2022
based on the old PR by @dragostis: pest-parser#277

Changes that were made:
- debugger core context was refactored and extracted to a lib (so that
it could be used in other frontends, e.g. editor plugins)
- CLI was extended using rustyline helpers to provide file completions,
history etc.
- applied suggestions from @hansihe from the old PR
(pest-parser#277 (comment)):
1. added `ba` (add breakpoints at all rules) which is useful
for stepping through the entire grammar, plus breakpoint deletions
and loading input directly from readline;
2. added command line arguments.
- changed the listener function to return a boolean, so that
the debugger can signal back to a parsing thread to finish
before reaching its input's EOF.
@tomtau
Copy link
Contributor

tomtau commented Nov 20, 2022

Made some improvements in this PR: #736

@tomtau tomtau closed this Nov 20, 2022
tomtau pushed a commit to tomtau/pest that referenced this pull request Nov 20, 2022
based on the old PR by @dragostis: pest-parser#277

Changes that were made:
- debugger core context was refactored and extracted to a lib (so that
it could be used in other frontends, e.g. editor plugins)
- CLI was extended using rustyline helpers to provide file completions,
history etc.
- applied suggestions from @hansihe from the old PR
(pest-parser#277 (comment)):
1. added `ba` (add breakpoints at all rules) which is useful
for stepping through the entire grammar, plus breakpoint deletions
and loading input directly from readline;
2. added command line arguments.
- changed the listener function to return a boolean, so that
the debugger can signal back to a parsing thread to finish
before reaching its input's EOF.

historyfile init
tomtau pushed a commit to tomtau/pest that referenced this pull request Nov 20, 2022
based on the old PR by @dragostis: pest-parser#277

Changes that were made:
- debugger core context was refactored and extracted to a lib (so that
it could be used in other frontends, e.g. editor plugins)
- CLI was extended using rustyline helpers to provide file completions,
history etc.
- applied suggestions from @hansihe from the old PR
(pest-parser#277 (comment)):
1. added `ba` (add breakpoints at all rules) which is useful
for stepping through the entire grammar, plus breakpoint deletions
and loading input directly from readline;
2. added command line arguments.
- changed the listener function to return a boolean, so that
the debugger can signal back to a parsing thread to finish
before reaching its input's EOF.

Co-authored-by: Dragoș Tiselice <dragostiselice@gmail.com>
tomtau added a commit that referenced this pull request Nov 24, 2022
* feature: added a `pest_debugger` crate (fixes #98)

based on the old PR by @dragostis: #277

Changes that were made:
- debugger core context was refactored and extracted to a lib (so that
it could be used in other frontends, e.g. editor plugins)
- CLI was extended using rustyline helpers to provide file completions,
history etc.
- applied suggestions from @hansihe from the old PR
(#277 (comment)):
1. added `ba` (add breakpoints at all rules) which is useful
for stepping through the entire grammar, plus breakpoint deletions
and loading input directly from readline;
2. added command line arguments.
- changed the listener function to return a boolean, so that
the debugger can signal back to a parsing thread to finish
before reaching its input's EOF.

Co-authored-by: Tomas Tauber <me@tomtau.be>
Co-authored-by: Dragoș Tiselice <dragostiselice@gmail.com>
@tomtau tomtau deleted the debugger branch April 18, 2023 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Grammar backtrace
3 participants