taocpp / PEGTL

Parsing Expression Grammar Template Library
Boost Software License 1.0
1.93k stars 232 forks source link

contrib/trace too verbose #364

Open jsawbbo opened 2 months ago

jsawbbo commented 2 months ago

Hi all.

I have just started using PEGTL, so I beg for patience - maybe I overlooked alternatives for this:

I try to implement a grammar for which I find the contrib/trace a bit too verbose in some cases.

I suggest to add a "nofollow" option which still traces the current node but not any child.

I attached a possible implementation. Usage:

struct my_rule : sor</* ... */>, trace_nofollow {};

This will still trace my_rule but nothing under it.

Cheers, George trace-nofollow.diff.gz

ColinH commented 1 month ago

We looked into this issue, it's a reasonable request for a useful feature! We'd like to take more time to choose a more flexible (disable tracing for sub-tree or individual rules) and/or simpler implementation (no additional vector in the tracer state), and also make it non-intrusive wrt. the grammar.