From 4fb816d55f47c48c34cc4478e584b1567a75863b Mon Sep 17 00:00:00 2001 From: Sergio Queiroz Date: Thu, 10 Jan 2019 10:06:33 -0300 Subject: Adapting lpeglabel-1.5 to the codebase of lpeg-1.0.0 --- lpprint.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'lpprint.c') diff --git a/lpprint.c b/lpprint.c index 3c6a8f6..393fc86 100644 --- a/lpprint.c +++ b/lpprint.c @@ -1,5 +1,5 @@ /* -** $Id: lpprint.c,v 1.10 2016/09/13 16:06:03 roberto Exp $ +** $Id: lpprint.c,v 1.9 2015/06/15 16:09:57 roberto Exp $ ** Copyright 2007, Lua.org & PUC-Rio (see 'lpeg.html' for license) */ @@ -37,13 +37,13 @@ void printcharset (const byte *st) { } -static const char *capkind (int kind) { +static void printcapkind (int kind) { const char *const modes[] = { "close", "position", "constant", "backref", "argument", "simple", "table", "function", "query", "string", "num", "substitution", "fold", "runtime", "group"}; - return modes[kind]; + printf("%s", modes[kind]); } @@ -60,7 +60,7 @@ void printinst (const Instruction *op, const Instruction *p) { "ret", "end", "choice", "pred_choice", "jmp", "call", "open_call", /* labeled failure */ "commit", "partial_commit", "back_commit", "failtwice", "fail", "giveup", - "fullcapture", "opencapture", "closecapture", "closeruntime", + "fullcapture", "opencapture", "closecapture", "closeruntime", "throw", "throw_rec", /* labeled failure */ }; printf("%02ld: %s ", (long)(p - op), names[p->i.code]); @@ -74,12 +74,13 @@ void printinst (const Instruction *op, const Instruction *p) { break; } case IFullCapture: { - printf("%s (size = %d) (idx = %d)", - capkind(getkind(p)), getoff(p), p->i.key); + printcapkind(getkind(p)); + printf(" (size = %d) (idx = %d)", getoff(p), p->i.key); break; } case IOpenCapture: { - printf("%s (idx = %d)", capkind(getkind(p)), p->i.key); + printcapkind(getkind(p)); + printf(" (idx = %d)", p->i.key); break; } case ISet: { @@ -133,8 +134,8 @@ void printpatt (Instruction *p, int n) { #if defined(LPEG_DEBUG) static void printcap (Capture *cap) { - printf("%s (idx: %d - size: %d) -> %p\n", - capkind(cap->kind), cap->idx, cap->siz, cap->s); + printcapkind(cap->kind); + printf(" (idx: %d - size: %d) -> %p\n", cap->idx, cap->siz, cap->s); } @@ -187,8 +188,7 @@ void printtree (TTree *tree, int ident) { break; } case TOpenCall: case TCall: { - assert(sib2(tree)->tag == TRule); - printf(" key: %d (rule: %d)\n", tree->key, sib2(tree)->cap); + printf(" key: %d\n", tree->key); break; } case TBehind: { @@ -197,7 +197,7 @@ void printtree (TTree *tree, int ident) { break; } case TCapture: { - printf(" kind: '%s' key: %d\n", capkind(tree->cap), tree->key); + printf(" cap: %d key: %d n: %d\n", tree->cap, tree->key, tree->u.n); printtree(sib1(tree), ident + 2); break; } -- cgit v1.2.3-55-g6feb