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
Even for a small input the output of trace can be big, I'm proposing to implement a way to trim down the output, as a prove of concept show bellow I'm accepting an optional integer value after the --trace option and using it to only show output with level <= opt_trace_level, ideally we would run it first with low trace level and will grow as needed depending on what we see in the reduced trace output, an enhanced version could also accept optional mim_position and or max_position to allow better control of the output.
Example of parsing the snippet bellow using the peglib grammar shown here #193 (comment) to parse it:
IdentStart <- [\u0080-\uFFFF]
With the actual --trace option we get 992 lines of output, with an optional trace level of 4 we get only 22 lines:
./peglint --trace 4 cpp-peglib.peg test.peg
opt_trace_level1 = 4
opt_trace_level2 = 4
E 0 ┌[Grammar] #0
E 0 │┌Sequence #1
E 0 ││┌[Spacing] #2
E 0 │││┌Repetition #3
E 0 ││││┌PrioritizedChoice #4
L 0 ││││└x PrioritizedChoice #4
L 0 │││└o Repetition #3
L 0 ││└o [Spacing] #2
E 0 ││┌Repetition #17
E 0 │││┌[Definition] #18
E 0 ││││┌PrioritizedChoice #19
L 30 ││││└o PrioritizedChoice #19 1/2
L 30 │││└o [Definition] #18
L 30 ││└o Repetition #17
E 30 ││┌[EndOfFile] #493
E 30 │││┌NotPredicate #494
E 30 ││││┌AnyCharacter #495
L 30 ││││└x AnyCharacter #495
L 30 │││└o NotPredicate #494, match ''
L 30 ││└o [EndOfFile] #493, match ''
L 30 │└o Sequence #1
L 30 └o [Grammar] #0
The text was updated successfully, but these errors were encountered:
Another interesting tool is https://github.com/mqnc/pegdebug but it stoped updating some time ago and doesn't works with the actual peglib it uses .enter, .match and .leave handlers and uses a call to any->get that doesn't exists anymore for indentation and looking at peglint that uses .trace_enter and trace_leave and get the indentation from Context can someone with more knowledge of the internals of peglib update pegdebug ?
Thank you for the suggestion, but I don't need the feature at this point for my project. Could you send a pull request, so that I can review the code and determine if it's worth to be merged. Thanks.
Even for a small input the output of trace can be big, I'm proposing to implement a way to trim down the output, as a prove of concept show bellow I'm accepting an optional integer value after the
--trace
option and using it to only show output with level <= opt_trace_level, ideally we would run it first with low trace level and will grow as needed depending on what we see in the reduced trace output, an enhanced version could also accept optionalmim_position
and ormax_position
to allow better control of the output.Example of parsing the snippet bellow using the
peglib
grammar shown here #193 (comment) to parse it:With the actual
--trace
option we get 992 lines of output, with an optional trace level of 4 we get only 22 lines:The text was updated successfully, but these errors were encountered: