diff options
author | Sérgio Queiroz <sqmedeiros@gmail.com> | 2017-12-15 14:17:20 -0300 |
---|---|---|
committer | Sérgio Queiroz <sqmedeiros@gmail.com> | 2017-12-15 14:17:20 -0300 |
commit | 0f53a65f4a32c8be2d84c4a8172b885065f7c1e5 (patch) | |
tree | 5d9f4535723c43f82451ad2e1e65da7810d4d082 /lptree.c | |
parent | bc071e9fe431347832fd424eb327357f38e60bfd (diff) | |
download | lpeglabel-0f53a65f4a32c8be2d84c4a8172b885065f7c1e5.tar.gz lpeglabel-0f53a65f4a32c8be2d84c4a8172b885065f7c1e5.tar.bz2 lpeglabel-0f53a65f4a32c8be2d84c4a8172b885065f7c1e5.zip |
Removing code related to previous recovery operator //{}
Diffstat (limited to 'lptree.c')
-rw-r--r-- | lptree.c | 29 |
1 files changed, 4 insertions, 25 deletions
@@ -527,10 +527,10 @@ static TTree *newroot2sib (lua_State *L, int tag) { | |||
527 | 527 | ||
528 | 528 | ||
529 | /* labeled failure begin */ | 529 | /* labeled failure begin */ |
530 | static TTree *newthrowleaf (lua_State *L, int lab) { | 530 | static TTree *newthrowleaf (lua_State *L) { |
531 | TTree *tree = newtree(L, 1); | 531 | TTree *tree = newtree(L, 1); |
532 | tree->tag = TThrow; | 532 | tree->tag = TThrow; |
533 | tree->u.s.ps = 0; | 533 | tree->u.s.ps = 0; /* there is no recovery rule associated */ |
534 | return tree; | 534 | return tree; |
535 | } | 535 | } |
536 | 536 | ||
@@ -730,35 +730,15 @@ static int lp_behind (lua_State *L) { | |||
730 | ** Throws a label | 730 | ** Throws a label |
731 | */ | 731 | */ |
732 | static int lp_throw (lua_State *L) { | 732 | static int lp_throw (lua_State *L) { |
733 | /*int label = luaL_checkinteger(L, -1);*/ | ||
734 | /*luaL_argcheck(L, label >= 1 && label < MAXLABELS, -1, "the number of a label must be between 1 and 255");*/ | ||
735 | TTree * tree; | 733 | TTree * tree; |
736 | luaL_checkstring(L, -1); | 734 | luaL_checkstring(L, -1); |
737 | tree = newthrowleaf(L, 0); | 735 | tree = newthrowleaf(L); |
738 | tree->key = addtonewktable(L, 0, 1); | 736 | tree->key = addtonewktable(L, 0, 1); |
739 | /*printf("lp_throw %d %s\n", tree->key, lua_tostring(L, 1));*/ | ||
740 | return 1; | 737 | return 1; |
741 | } | 738 | } |
742 | 739 | ||
743 | 740 | ||
744 | /* | 741 | /* |
745 | ** labeled recovery function | ||
746 | */ | ||
747 | static int lp_recovery (lua_State *L) { | ||
748 | int n = lua_gettop(L); | ||
749 | TTree *tree = newrootlab2sib(L, TRecov); | ||
750 | int i; | ||
751 | luaL_argcheck(L, n >= 3, 3, "non-nil value expected"); | ||
752 | for (i = 3; i <= n; i++) { | ||
753 | int d = luaL_checkinteger(L, i); | ||
754 | luaL_argcheck(L, d >= 1 && d < MAXLABELS, i, "the number of a label must be between 1 and 255"); | ||
755 | setlabel(treelabelset(tree), (byte)d); | ||
756 | } | ||
757 | return 1; | ||
758 | } | ||
759 | |||
760 | |||
761 | /* | ||
762 | ** labeled choice function | 742 | ** labeled choice function |
763 | */ | 743 | */ |
764 | static int lp_labchoice (lua_State *L) { | 744 | static int lp_labchoice (lua_State *L) { |
@@ -1108,7 +1088,7 @@ static int verifyrule (lua_State *L, TTree *tree, int *passed, int npassed, | |||
1108 | return nb; | 1088 | return nb; |
1109 | /* else return verifyrule(L, sib2(tree), passed, npassed, nb); */ | 1089 | /* else return verifyrule(L, sib2(tree), passed, npassed, nb); */ |
1110 | tree = sib2(tree); goto tailcall; | 1090 | tree = sib2(tree); goto tailcall; |
1111 | case TChoice: case TRecov: case TLabChoice: /* must check both children */ /* labeled failure */ | 1091 | case TChoice: case TLabChoice: /* must check both children */ /* labeled failure */ |
1112 | nb = verifyrule(L, sib1(tree), passed, npassed, nb); | 1092 | nb = verifyrule(L, sib1(tree), passed, npassed, nb); |
1113 | /* return verifyrule(L, sib2(tree), passed, npassed, nb); */ | 1093 | /* return verifyrule(L, sib2(tree), passed, npassed, nb); */ |
1114 | tree = sib2(tree); goto tailcall; | 1094 | tree = sib2(tree); goto tailcall; |
@@ -1364,7 +1344,6 @@ static struct luaL_Reg pattreg[] = { | |||
1364 | {"setmaxstack", lp_setmax}, | 1344 | {"setmaxstack", lp_setmax}, |
1365 | {"type", lp_type}, | 1345 | {"type", lp_type}, |
1366 | {"T", lp_throw}, /* labeled failure throw */ | 1346 | {"T", lp_throw}, /* labeled failure throw */ |
1367 | {"Rec", lp_recovery}, /* labeled failure recovery */ | ||
1368 | {"Lc", lp_labchoice}, /* labeled failure choice */ | 1347 | {"Lc", lp_labchoice}, /* labeled failure choice */ |
1369 | {NULL, NULL} | 1348 | {NULL, NULL} |
1370 | }; | 1349 | }; |