aboutsummaryrefslogtreecommitdiff
path: root/lpprint.c
diff options
context:
space:
mode:
authorSergio Queiroz <sqmedeiros@gmail.com>2019-01-10 10:06:33 -0300
committerSergio Queiroz <sqmedeiros@gmail.com>2019-01-10 10:06:33 -0300
commit4fb816d55f47c48c34cc4478e584b1567a75863b (patch)
tree54ec6965c9d3983b193cf000a521a06cb3d73b8a /lpprint.c
parent9be59fb8f4b176a16643e707c74051b243202296 (diff)
downloadlpeglabel-lpeg-1.0.0.tar.gz
lpeglabel-lpeg-1.0.0.tar.bz2
lpeglabel-lpeg-1.0.0.zip
Adapting lpeglabel-1.5 to the codebase of lpeg-1.0.0lpeg-1.0.0
Diffstat (limited to 'lpprint.c')
-rw-r--r--lpprint.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/lpprint.c b/lpprint.c
index 3c6a8f6..393fc86 100644
--- a/lpprint.c
+++ b/lpprint.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lpprint.c,v 1.10 2016/09/13 16:06:03 roberto Exp $ 2** $Id: lpprint.c,v 1.9 2015/06/15 16:09:57 roberto Exp $
3** Copyright 2007, Lua.org & PUC-Rio (see 'lpeg.html' for license) 3** Copyright 2007, Lua.org & PUC-Rio (see 'lpeg.html' for license)
4*/ 4*/
5 5
@@ -37,13 +37,13 @@ void printcharset (const byte *st) {
37} 37}
38 38
39 39
40static const char *capkind (int kind) { 40static void printcapkind (int kind) {
41 const char *const modes[] = { 41 const char *const modes[] = {
42 "close", "position", "constant", "backref", 42 "close", "position", "constant", "backref",
43 "argument", "simple", "table", "function", 43 "argument", "simple", "table", "function",
44 "query", "string", "num", "substitution", "fold", 44 "query", "string", "num", "substitution", "fold",
45 "runtime", "group"}; 45 "runtime", "group"};
46 return modes[kind]; 46 printf("%s", modes[kind]);
47} 47}
48 48
49 49
@@ -60,7 +60,7 @@ void printinst (const Instruction *op, const Instruction *p) {
60 "ret", "end", 60 "ret", "end",
61 "choice", "pred_choice", "jmp", "call", "open_call", /* labeled failure */ 61 "choice", "pred_choice", "jmp", "call", "open_call", /* labeled failure */
62 "commit", "partial_commit", "back_commit", "failtwice", "fail", "giveup", 62 "commit", "partial_commit", "back_commit", "failtwice", "fail", "giveup",
63 "fullcapture", "opencapture", "closecapture", "closeruntime", 63 "fullcapture", "opencapture", "closecapture", "closeruntime",
64 "throw", "throw_rec", /* labeled failure */ 64 "throw", "throw_rec", /* labeled failure */
65 }; 65 };
66 printf("%02ld: %s ", (long)(p - op), names[p->i.code]); 66 printf("%02ld: %s ", (long)(p - op), names[p->i.code]);
@@ -74,12 +74,13 @@ void printinst (const Instruction *op, const Instruction *p) {
74 break; 74 break;
75 } 75 }
76 case IFullCapture: { 76 case IFullCapture: {
77 printf("%s (size = %d) (idx = %d)", 77 printcapkind(getkind(p));
78 capkind(getkind(p)), getoff(p), p->i.key); 78 printf(" (size = %d) (idx = %d)", getoff(p), p->i.key);
79 break; 79 break;
80 } 80 }
81 case IOpenCapture: { 81 case IOpenCapture: {
82 printf("%s (idx = %d)", capkind(getkind(p)), p->i.key); 82 printcapkind(getkind(p));
83 printf(" (idx = %d)", p->i.key);
83 break; 84 break;
84 } 85 }
85 case ISet: { 86 case ISet: {
@@ -133,8 +134,8 @@ void printpatt (Instruction *p, int n) {
133 134
134#if defined(LPEG_DEBUG) 135#if defined(LPEG_DEBUG)
135static void printcap (Capture *cap) { 136static void printcap (Capture *cap) {
136 printf("%s (idx: %d - size: %d) -> %p\n", 137 printcapkind(cap->kind);
137 capkind(cap->kind), cap->idx, cap->siz, cap->s); 138 printf(" (idx: %d - size: %d) -> %p\n", cap->idx, cap->siz, cap->s);
138} 139}
139 140
140 141
@@ -187,8 +188,7 @@ void printtree (TTree *tree, int ident) {
187 break; 188 break;
188 } 189 }
189 case TOpenCall: case TCall: { 190 case TOpenCall: case TCall: {
190 assert(sib2(tree)->tag == TRule); 191 printf(" key: %d\n", tree->key);
191 printf(" key: %d (rule: %d)\n", tree->key, sib2(tree)->cap);
192 break; 192 break;
193 } 193 }
194 case TBehind: { 194 case TBehind: {
@@ -197,7 +197,7 @@ void printtree (TTree *tree, int ident) {
197 break; 197 break;
198 } 198 }
199 case TCapture: { 199 case TCapture: {
200 printf(" kind: '%s' key: %d\n", capkind(tree->cap), tree->key); 200 printf(" cap: %d key: %d n: %d\n", tree->cap, tree->key, tree->u.n);
201 printtree(sib1(tree), ident + 2); 201 printtree(sib1(tree), ident + 2);
202 break; 202 break;
203 } 203 }