aboutsummaryrefslogtreecommitdiff
path: root/lpcode.c
diff options
context:
space:
mode:
Diffstat (limited to 'lpcode.c')
-rw-r--r--lpcode.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/lpcode.c b/lpcode.c
index 1036fdf..ef357bc 100644
--- a/lpcode.c
+++ b/lpcode.c
@@ -449,7 +449,7 @@ int sizei (const Instruction *i) {
449 case ITestChar: case ITestAny: case IChoice: case IJmp: case ICall: 449 case ITestChar: case ITestAny: case IChoice: case IJmp: case ICall:
450 case IOpenCall: case ICommit: case IPartialCommit: case IBackCommit: 450 case IOpenCall: case ICommit: case IPartialCommit: case IBackCommit:
451 return 2; 451 return 2;
452 case IThrow: /* labeled failure */ 452 case IThrow: case IPredChoice: /* labeled failure */
453 return 2; 453 return 2;
454 case IThrowRec: /* labeled failure */ 454 case IThrowRec: /* labeled failure */
455 return 3; 455 return 3;
@@ -747,15 +747,19 @@ static void codechoice (CompileState *compst, TTree *p1, TTree *p2, int opt,
747** (valid only when 'p' has no captures) 747** (valid only when 'p' has no captures)
748*/ 748*/
749static void codeand (CompileState *compst, TTree *tree, int tt) { 749static void codeand (CompileState *compst, TTree *tree, int tt) {
750 int n = fixedlen(tree); 750 /* labeled failure: optimization disabled bacause in case of a failure it
751 does not report the expected error position (the current subject position
752 when begin the matching of <&p>) */
753 /*int n = fixedlen(tree);
751 if (n >= 0 && n <= MAXBEHIND && !hascaptures(tree)) { 754 if (n >= 0 && n <= MAXBEHIND && !hascaptures(tree)) {
752 codegen(compst, tree, 0, tt, fullset); 755 codegen(compst, tree, 0, tt, fullset);
753 if (n > 0) 756 if (n > 0)
754 addinstruction(compst, IBehind, n); 757 addinstruction(compst, IBehind, n);
755 } 758 }
756 else { /* default: Choice L1; p1; BackCommit L2; L1: Fail; L2: */ 759 else */{ /* default: Choice L1; p1; BackCommit L2; L1: Fail; L2: */
757 int pcommit; 760 int pcommit;
758 int pchoice = addoffsetinst(compst, IChoice); 761 int pchoice = addoffsetinst(compst, IPredChoice); /* labeled failure */
762 getinstr(compst, pchoice).i.aux = ANDPRED;
759 codegen(compst, tree, 0, tt, fullset); 763 codegen(compst, tree, 0, tt, fullset);
760 pcommit = addoffsetinst(compst, IBackCommit); 764 pcommit = addoffsetinst(compst, IBackCommit);
761 jumptohere(compst, pchoice); 765 jumptohere(compst, pchoice);
@@ -857,7 +861,8 @@ static void codenot (CompileState *compst, TTree *tree) {
857 addinstruction(compst, IFail, 0); 861 addinstruction(compst, IFail, 0);
858 else { 862 else {
859 /* test(fail(p))-> L1; choice L1; <p>; failtwice; L1: */ 863 /* test(fail(p))-> L1; choice L1; <p>; failtwice; L1: */
860 int pchoice = addoffsetinst(compst, IChoice); 864 int pchoice = addoffsetinst(compst, IPredChoice); /* labeled failure */
865 getinstr(compst, pchoice).i.aux = NOTPRED;
861 codegen(compst, tree, 0, NOINST, fullset); 866 codegen(compst, tree, 0, NOINST, fullset);
862 addinstruction(compst, IFailTwice, 0); 867 addinstruction(compst, IFailTwice, 0);
863 jumptohere(compst, pchoice); 868 jumptohere(compst, pchoice);