question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Debugging support

See original GitHub issue

It’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:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:18 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
mixturcommented, Jul 4, 2017

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. debugExample

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

alt(
  seq(a, b),
  seq(a, c)
)
1reaction
wavebeemcommented, May 24, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found