Debugging support
See original GitHub issueIt’d be nice to have a way to show what Parsimmon does under the hood. This should help trace bugs in complicated parsers. Maybe using debug or something similar.
For instance:
const parser = P.alt(
P.regexp(/[0-9]+/i),
P.regexp(/[a-z]+/i)
).many()
parser.parse('hello10')
I’d like to be able to see something like:
[0:0] "hello10"
alt(2):
regexp(/[0-9]+/i): fail
regexp(/[a-z]+/i): "hello"
[0:5] "10"
alt(2):
regexp(/[0-9]+/i): "10"
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:18 (5 by maintainers)
Top Results From Across the Web
Debugging Support - open-std.org
The debugging support functionality is particularly useful in situations where it's difficult to debug in traditional hosted context.
Read more >Debugging Support - GCC, the GNU Compiler Collection
Debugging Support. There are numerous things that can be done to improve the ease with which C++ binaries are debugged when using the...
Read more >Debugging in Visual Studio Code
One of the great things in Visual Studio Code is debugging support. Set breakpoints, step-in, inspect variables and more.
Read more >Debugging - Support - Apple Developer
Learn how to efficiently discover and resolve issues with your app.
Read more >7 Debugging Techniques to Speed Up Troubleshooting | Toptal
7 Debugging Techniques To Speed Up Troubleshooting in Production. Providing production support to an application is one of the most challenging aspects of ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
At some point I made these helpers for my language’s parser.
It generates output that looks like this when logAnnotations is set to true.
It helped me to find a few bugs that were very hard to find otherwise.
And having this experience, I will probably do it differently next time. Since I was logging everything at the moment of parsing I could only tell if parser succeeded or failed AFTER it was done; so the tree structure is kinda upside down (children first, root last). So maybe it would be better not to log everything at parsing time, But collect data about parsing process, and then provide a way to log it.
There is also sinCounter / breakOnRepeat / MAX_SINS. It helped me to locate cases that looked like
I did just have a thought though that using the upcoming
createLanguage
API we could automatically add a debugging name equal to the object key! On top of that we could just keep track of parse depth and print the debug name with appropriate indentation, and this might actually be useful.