aboutsummaryrefslogtreecommitdiff
path: root/lptree.c
diff options
context:
space:
mode:
authorSergio Queiroz <sqmedeiros@gmail.com>2019-01-10 10:06:33 -0300
committerSergio Queiroz <sqmedeiros@gmail.com>2019-01-10 10:06:33 -0300
commit4fb816d55f47c48c34cc4478e584b1567a75863b (patch)
tree54ec6965c9d3983b193cf000a521a06cb3d73b8a /lptree.c
parent9be59fb8f4b176a16643e707c74051b243202296 (diff)
downloadlpeglabel-lpeg-1.0.0.tar.gz
lpeglabel-lpeg-1.0.0.tar.bz2
lpeglabel-lpeg-1.0.0.zip
Adapting lpeglabel-1.5 to the codebase of lpeg-1.0.0lpeg-1.0.0
Diffstat (limited to 'lptree.c')
-rw-r--r--lptree.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/lptree.c b/lptree.c
index 33ae79d..96d3079 100644
--- a/lptree.c
+++ b/lptree.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lptree.c,v 1.22 2016/09/13 18:10:22 roberto Exp $ 2** $Id: lptree.c,v 1.21 2015/09/28 17:01:25 roberto Exp $
3** Copyright 2013, Lua.org & PUC-Rio (see 'lpeg.html' for license) 3** Copyright 2013, Lua.org & PUC-Rio (see 'lpeg.html' for license)
4*/ 4*/
5 5
@@ -66,7 +66,7 @@ static void fixonecall (lua_State *L, int postable, TTree *g, TTree *t, byte tag
66 t->tag = TCall; 66 t->tag = TCall;
67 t->u.ps = n - (t - g); /* position relative to node */ 67 t->u.ps = n - (t - g); /* position relative to node */
68 assert(sib2(t)->tag == TRule); 68 assert(sib2(t)->tag == TRule);
69 sib2(t)->key = t->key; /* fix rule's key */ 69 sib2(t)->key = t->key;
70 } else if (n != 0) { /* labeled failure */ 70 } else if (n != 0) { /* labeled failure */
71 t->u.ps = n - (t - g); /* position relative to node */ 71 t->u.ps = n - (t - g); /* position relative to node */
72 } 72 }
@@ -969,7 +969,7 @@ static void buildgrammar (lua_State *L, TTree *grammar, int frule, int n) {
969 int rulesize; 969 int rulesize;
970 TTree *rn = gettree(L, ridx, &rulesize); 970 TTree *rn = gettree(L, ridx, &rulesize);
971 nd->tag = TRule; 971 nd->tag = TRule;
972 nd->key = 0; /* will be fixed when rule is used */ 972 nd->key = 0;
973 nd->cap = i; /* rule number */ 973 nd->cap = i; /* rule number */
974 nd->u.ps = rulesize + 1; /* point to next rule */ 974 nd->u.ps = rulesize + 1; /* point to next rule */
975 memcpy(sib1(nd), rn, rulesize * sizeof(TTree)); /* copy rule */ 975 memcpy(sib1(nd), rn, rulesize * sizeof(TTree)); /* copy rule */
@@ -1003,11 +1003,6 @@ static int checkloops (TTree *tree) {
1003} 1003}
1004 1004
1005 1005
1006/*
1007** Give appropriate error message for 'verifyrule'. If a rule appears
1008** twice in 'passed', there is path from it back to itself without
1009** advancing the subject.
1010*/
1011static int verifyerror (lua_State *L, int *passed, int npassed) { 1006static int verifyerror (lua_State *L, int *passed, int npassed) {
1012 int i, j; 1007 int i, j;
1013 for (i = npassed - 1; i >= 0; i--) { /* search for a repetition */ 1008 for (i = npassed - 1; i >= 0; i--) { /* search for a repetition */
@@ -1029,8 +1024,6 @@ static int verifyerror (lua_State *L, int *passed, int npassed) {
1029** is only relevant if the first is nullable. 1024** is only relevant if the first is nullable.
1030** Parameter 'nb' works as an accumulator, to allow tail calls in 1025** Parameter 'nb' works as an accumulator, to allow tail calls in
1031** choices. ('nb' true makes function returns true.) 1026** choices. ('nb' true makes function returns true.)
1032** Parameter 'passed' is a list of already visited rules, 'npassed'
1033** counts the elements in 'passed'.
1034** Assume ktable at the top of the stack. 1027** Assume ktable at the top of the stack.
1035*/ 1028*/
1036static int verifyrule (lua_State *L, TTree *tree, int *passed, int npassed, 1029static int verifyrule (lua_State *L, TTree *tree, int *passed, int npassed,