aboutsummaryrefslogtreecommitdiff
path: root/lpprint.c
diff options
context:
space:
mode:
Diffstat (limited to 'lpprint.c')
-rw-r--r--lpprint.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/lpprint.c b/lpprint.c
index 0730ca9..d4a60a8 100644
--- a/lpprint.c
+++ b/lpprint.c
@@ -52,7 +52,7 @@ static void printjmp (const Instruction *op, const Instruction *p) {
52} 52}
53 53
54 54
55void printinst (const Instruction *op, const Instruction *p) { 55static void printinst (const Instruction *op, const Instruction *p) {
56 const char *const names[] = { 56 const char *const names[] = {
57 "any", "char", "set", 57 "any", "char", "set",
58 "testany", "testchar", "testset", 58 "testany", "testchar", "testset",
@@ -60,8 +60,8 @@ void printinst (const Instruction *op, const Instruction *p) {
60 "ret", "end", 60 "ret", "end",
61 "choice", "jmp", "call", "open_call", 61 "choice", "jmp", "call", "open_call",
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", "labeled_choice" /* labeled failure */ 64 "throw", "labeled_choice" /* 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]);
67 switch ((Opcode)p->i.code) { 67 switch ((Opcode)p->i.code) {
@@ -103,12 +103,12 @@ void printinst (const Instruction *op, const Instruction *p) {
103 printf("%d", p->i.aux); 103 printf("%d", p->i.aux);
104 break; 104 break;
105 } 105 }
106 case IJmp: case ICall: case ICommit: case IChoice: 106 case IJmp: case ICall: case ICommit: case IChoice:
107 case IPartialCommit: case IBackCommit: case ITestAny: { 107 case IPartialCommit: case IBackCommit: case ITestAny: {
108 printjmp(op, p); 108 printjmp(op, p);
109 break; 109 break;
110 } 110 }
111 case IThrow: { /* labeled failure */ 111 case IThrow: { /* labeled failure */
112 printf("%d", (p + 1)->labels); 112 printf("%d", (p + 1)->labels);
113 break; 113 break;
114 } 114 }
@@ -117,7 +117,6 @@ void printinst (const Instruction *op, const Instruction *p) {
117 printf(" %d", (p + 2)->labels); 117 printf(" %d", (p + 2)->labels);
118 break; 118 break;
119 } 119 }
120
121 default: break; 120 default: break;
122 } 121 }
123 printf("\n"); 122 printf("\n");
@@ -194,7 +193,7 @@ void printtree (TTree *tree, int ident) {
194 } 193 }
195 case TBehind: { 194 case TBehind: {
196 printf(" %d\n", tree->u.n); 195 printf(" %d\n", tree->u.n);
197 printtree(sib1(tree), ident + 2); 196 printtree(sib1(tree), ident + 2);
198 break; 197 break;
199 } 198 }
200 case TCapture: { 199 case TCapture: {
@@ -217,16 +216,16 @@ void printtree (TTree *tree, int ident) {
217 assert(rule->tag == TTrue); /* sentinel */ 216 assert(rule->tag == TTrue); /* sentinel */
218 break; 217 break;
219 } 218 }
220 case TThrow: { /* labeled failure */ 219 case TThrow: { /* labeled failure */
221 printf(" labels: %d\n", tree->labels); 220 printf(" labels: %d\n", tree->labels);
222 break; 221 break;
223 } 222 }
224 default: { 223 default: {
225 int sibs = numsiblings[tree->tag]; 224 int sibs = numsiblings[tree->tag];
226 if (tree->tag == TLabChoice) { /* labeled failure */ 225 printf("\n");
226 if (tree->tag == TLabChoice) { /* labeled failure */
227 printf(" labels: %d\n", tree->labels); 227 printf(" labels: %d\n", tree->labels);
228 } 228 }
229 printf("\n");
230 if (sibs >= 1) { 229 if (sibs >= 1) {
231 printtree(sib1(tree), ident + 2); 230 printtree(sib1(tree), ident + 2);
232 if (sibs >= 2) 231 if (sibs >= 2)