aboutsummaryrefslogtreecommitdiff
path: root/lpprint.c
diff options
context:
space:
mode:
authorSergio Queiroz <sqmedeiros@gmail.com>2017-07-06 11:21:56 -0300
committerSergio Queiroz <sqmedeiros@gmail.com>2017-07-06 11:21:56 -0300
commit8ee42c29131e1c7de48575d6d8a9b24ea6977cbd (patch)
tree4267e0cf0609a909be1f2eaea17d11b0efc12c98 /lpprint.c
parentaad9b29e755d67d6cb4e4b861111df0d173819ce (diff)
downloadlpeglabel-8ee42c29131e1c7de48575d6d8a9b24ea6977cbd.tar.gz
lpeglabel-8ee42c29131e1c7de48575d6d8a9b24ea6977cbd.tar.bz2
lpeglabel-8ee42c29131e1c7de48575d6d8a9b24ea6977cbd.zip
Updating lpeglabel to the codebase of LPeg 1.0.1
Diffstat (limited to 'lpprint.c')
-rw-r--r--lpprint.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/lpprint.c b/lpprint.c
index 8c488ea..ecaa7f1 100644
--- a/lpprint.c
+++ b/lpprint.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lpprint.c,v 1.9 2015/06/15 16:09:57 roberto Exp $ 2** $Id: lpprint.c,v 1.10 2016/09/13 16:06:03 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 void printcapkind (int kind) { 40static const char *capkind (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 printf("%s", modes[kind]); 46 return modes[kind];
47} 47}
48 48
49 49
@@ -74,13 +74,12 @@ void printinst (const Instruction *op, const Instruction *p) {
74 break; 74 break;
75 } 75 }
76 case IFullCapture: { 76 case IFullCapture: {
77 printcapkind(getkind(p)); 77 printf("%s (size = %d) (idx = %d)",
78 printf(" (size = %d) (idx = %d)", getoff(p), p->i.key); 78 capkind(getkind(p)), getoff(p), p->i.key);
79 break; 79 break;
80 } 80 }
81 case IOpenCapture: { 81 case IOpenCapture: {
82 printcapkind(getkind(p)); 82 printf("%s (idx = %d)", capkind(getkind(p)), p->i.key);
83 printf(" (idx = %d)", p->i.key);
84 break; 83 break;
85 } 84 }
86 case ISet: { 85 case ISet: {
@@ -134,8 +133,8 @@ void printpatt (Instruction *p, int n) {
134 133
135#if defined(LPEG_DEBUG) 134#if defined(LPEG_DEBUG)
136static void printcap (Capture *cap) { 135static void printcap (Capture *cap) {
137 printcapkind(cap->kind); 136 printf("%s (idx: %d - size: %d) -> %p\n",
138 printf(" (idx: %d - size: %d) -> %p\n", cap->idx, cap->siz, cap->s); 137 capkind(cap->kind), cap->idx, cap->siz, cap->s);
139} 138}
140 139
141 140
@@ -188,7 +187,8 @@ void printtree (TTree *tree, int ident) {
188 break; 187 break;
189 } 188 }
190 case TOpenCall: case TCall: { 189 case TOpenCall: case TCall: {
191 printf(" key: %d\n", tree->key); 190 assert(sib2(tree)->tag == TRule);
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(" cap: %d key: %d n: %d\n", tree->cap, tree->key, tree->u.n); 200 printf(" kind: '%s' key: %d\n", capkind(tree->cap), tree->key);
201 printtree(sib1(tree), ident + 2); 201 printtree(sib1(tree), ident + 2);
202 break; 202 break;
203 } 203 }