CompilerTeaching / Pegmatite

A library for reusable parsers
http://compilerteaching.github.io/pegmatite/
BSD 2-Clause "Simplified" License
16 stars 9 forks source link

TraceExpr do not trigger trace messages if rules are matched from the cache #27

Open varkor opened 7 years ago

varkor commented 7 years ago

Usually the trace() function will provide helpful messages when rules are matched. However, if a rule is matched from the cache (https://github.com/CompilerTeaching/Pegmatite/blob/ba2350f5d72aeed84f6f7cb715f9317323643574/parser.cc#L1226), then no message will be displayed, which can be confusing when trying to debug a grammar.

davidchisnall commented 7 years ago

I'm not sure what the best solution here is. We could either simply disable the cache when tracing is enabled (simple, but slows things down a lot), or we could query matches to see if they contain any traces (potentially expensive) when we fetch them from the cache and add another method for triggering the trace.