Closed robinwils closed 9 years ago
IIRC, you can evoke any rule by calling YourGramme.ruleX( ... ). That bypasses the call to decimateTree and should give you a more complete parse tree. You could use it to call the very first rule of your gramme. But that's still not logging per se.
Or else, you could add a logging action after your rules (or some selected, low level rules). Here is a small program demonstrating this:
import std.stdio;
//import std.typecons;
//import std.typetuple;
import pegged.grammar;
PT log(PT)(PT p)
{
writeln("Logging: ", p);
return p;
}
mixin(grammar("
MyGram:
A <{log} 'a' B
B <{log} C*
C <{log} 'b'
"));
void main() {
// Non-decimated tree:
writeln(MyGram.A("abbbb_"));
}
Another possibility would be to use the fail
pre-defined rule, which
makes the rule fail. So in way it can be used as a breakpoint.
Thanks for the tips, I wasn't using the Semantic Actions properly apparently !
Good! Keep me informed if you have any other difficulty.
On Tue, Mar 17, 2015 at 5:57 PM, Robin WILS notifications@github.com wrote:
Thanks for the tips, I wasn't using the Semantic Actions properly apparently !
— Reply to this email directly or view it on GitHub https://github.com/PhilippeSigaud/Pegged/issues/150#issuecomment-82478471 .
Hi,
Is there a way to make the parser verbose ? I have a problem where the parser generated is segfaulting in result of a stack overflow but I can't really see what is going on in GDB. Any tips would be appreciated.