aboutsummaryrefslogtreecommitdiff
path: root/lptree.c
diff options
context:
space:
mode:
authorSergio <sqmedeiros@gmail.com>2019-06-21 18:07:07 -0300
committerSergio <sqmedeiros@gmail.com>2019-06-21 18:07:07 -0300
commit0671e873f50ba568074d1683e068d5dce88dd43b (patch)
tree373f46d1c3fac997803835155a5ba764bbcbd250 /lptree.c
parent0f48dada44ec37bec8ef1b44ef8b621716ca5c05 (diff)
downloadlpeglabel-0671e873f50ba568074d1683e068d5dce88dd43b.tar.gz
lpeglabel-0671e873f50ba568074d1683e068d5dce88dd43b.tar.bz2
lpeglabel-0671e873f50ba568074d1683e068d5dce88dd43b.zip
Updating LPegLabel to the codebase of LPeg 1.0.2
Diffstat (limited to 'lptree.c')
-rw-r--r--lptree.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/lptree.c b/lptree.c
index 33ae79d..b1a32c4 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 $
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
@@ -750,6 +750,7 @@ static int capture_aux (lua_State *L, int cap, int labelidx) {
750 750
751/* 751/*
752** Fill a tree with an empty capture, using an empty (TTrue) sibling. 752** Fill a tree with an empty capture, using an empty (TTrue) sibling.
753** (The 'key' field must be filled by the caller to finish the tree.)
753*/ 754*/
754static TTree *auxemptycap (TTree *tree, int cap) { 755static TTree *auxemptycap (TTree *tree, int cap) {
755 tree->tag = TCapture; 756 tree->tag = TCapture;
@@ -760,15 +761,17 @@ static TTree *auxemptycap (TTree *tree, int cap) {
760 761
761 762
762/* 763/*
763** Create a tree for an empty capture 764** Create a tree for an empty capture.
764*/ 765*/
765static TTree *newemptycap (lua_State *L, int cap) { 766static TTree *newemptycap (lua_State *L, int cap, int key) {
766 return auxemptycap(newtree(L, 2), cap); 767 TTree *tree = auxemptycap(newtree(L, 2), cap);
768 tree->key = key;
769 return tree;
767} 770}
768 771
769 772
770/* 773/*
771** Create a tree for an empty capture with an associated Lua value 774** Create a tree for an empty capture with an associated Lua value.
772*/ 775*/
773static TTree *newemptycapkey (lua_State *L, int cap, int idx) { 776static TTree *newemptycapkey (lua_State *L, int cap, int idx) {
774 TTree *tree = auxemptycap(newtree(L, 2), cap); 777 TTree *tree = auxemptycap(newtree(L, 2), cap);
@@ -829,16 +832,15 @@ static int lp_simplecapture (lua_State *L) {
829 832
830 833
831static int lp_poscapture (lua_State *L) { 834static int lp_poscapture (lua_State *L) {
832 newemptycap(L, Cposition); 835 newemptycap(L, Cposition, 0);
833 return 1; 836 return 1;
834} 837}
835 838
836 839
837static int lp_argcapture (lua_State *L) { 840static int lp_argcapture (lua_State *L) {
838 int n = (int)luaL_checkinteger(L, 1); 841 int n = (int)luaL_checkinteger(L, 1);
839 TTree *tree = newemptycap(L, Carg);
840 tree->key = n;
841 luaL_argcheck(L, 0 < n && n <= SHRT_MAX, 1, "invalid argument index"); 842 luaL_argcheck(L, 0 < n && n <= SHRT_MAX, 1, "invalid argument index");
843 newemptycap(L, Carg, n);
842 return 1; 844 return 1;
843} 845}
844 846