aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergio Medeiros <sqmedeiros@gmail.com>2014-10-30 16:31:23 -0300
committerSergio Medeiros <sqmedeiros@gmail.com>2014-10-30 16:31:23 -0300
commita7d952491eab8839d5b0df056b13954c575d16e5 (patch)
treeb1d465c5f6ed06f4686d9378968cd9571f353319
parent5cc11088848a7884980bc00a96c9f3189e6de505 (diff)
downloadlpeglabel-a7d952491eab8839d5b0df056b13954c575d16e5.tar.gz
lpeglabel-a7d952491eab8839d5b0df056b13954c575d16e5.tar.bz2
lpeglabel-a7d952491eab8839d5b0df056b13954c575d16e5.zip
Minor changes in lpcode.c
-rw-r--r--lpcode.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/lpcode.c b/lpcode.c
index 4a49e7d..4431146 100644
--- a/lpcode.c
+++ b/lpcode.c
@@ -272,8 +272,8 @@ static int getfirst (TTree *tree, const Charset *follow, Charset *firstset) {
272 loopset(i, firstset->cs[i] = 0); 272 loopset(i, firstset->cs[i] = 0);
273 return 0; 273 return 0;
274 } 274 }
275 case TThrow: { /* (?)labeled failure: should always throw the label */ 275 case TThrow: { /* labeled failure: must always throw the label */
276 loopset(i, firstset->cs[i] = follow->cs[i]); /* follow = fullset? */ 276 loopset(i, firstset->cs[i] = follow->cs[i]); /* follow = fullset(?) */
277 return 1; 277 return 1;
278 } 278 }
279 case TChoice: case TLabChoice: { /*(?) labeled failure */ 279 case TChoice: case TLabChoice: { /*(?) labeled failure */
@@ -350,7 +350,7 @@ static int headfail (TTree *tree) {
350 return 1; 350 return 1;
351 case TTrue: case TRep: case TRunTime: case TNot: 351 case TTrue: case TRep: case TRunTime: case TNot:
352 case TBehind: 352 case TBehind:
353 case TThrow: /* labeled failure: should always throw the label */ 353 case TThrow: /* labeled failure: must always throw the label */
354 return 0; 354 return 0;
355 case TCapture: case TGrammar: case TRule: case TAnd: 355 case TCapture: case TGrammar: case TRule: case TAnd:
356 tree = sib1(tree); goto tailcall; /* return headfail(sib1(tree)); */ 356 tree = sib1(tree); goto tailcall; /* return headfail(sib1(tree)); */
@@ -486,13 +486,12 @@ static int addthrowinstruction (CompileState *compst, Labelset ls) {
486 return i; 486 return i;
487} 487}
488 488
489static int addoffsetlabinst (CompileState *compst, Opcode op, Labelset ls) { 489static int addoffsetlabinst (CompileState *compst, Labelset ls) {
490 int j; 490 int j;
491 int i = addinstruction(compst, op, 0); /* instruction */ 491 int i = addinstruction(compst, ILabChoice, 0); /* instruction */
492 addinstruction(compst, (Opcode)0, 0); /* open space for offset */ 492 addinstruction(compst, (Opcode)0, 0); /* open space for offset */
493 j = nextinstruction(compst); /* open space for labels */ 493 j = nextinstruction(compst); /* open space for labels */
494 getinstr(compst, j).labels = ls; 494 getinstr(compst, j).labels = ls;
495 assert(op == ILabChoice);
496 return i; 495 return i;
497} 496}
498/* labeled failure end */ 497/* labeled failure end */
@@ -697,7 +696,7 @@ static void codelabchoice (CompileState *compst, TTree *p1, TTree *p2, int opt,
697 int emptyp2 = (p2->tag == TTrue); 696 int emptyp2 = (p2->tag == TTrue);
698 int pcommit; 697 int pcommit;
699 int test = NOINST; 698 int test = NOINST;
700 int pchoice = addoffsetlabinst(compst, ILabChoice, ls); 699 int pchoice = addoffsetlabinst(compst, ls);
701 codegen(compst, p1, emptyp2, test, fullset); 700 codegen(compst, p1, emptyp2, test, fullset);
702 pcommit = addoffsetinst(compst, ICommit); 701 pcommit = addoffsetinst(compst, ICommit);
703 jumptohere(compst, pchoice); 702 jumptohere(compst, pchoice);