diff options
author | Sergio <sqmedeiros@gmail.com> | 2019-06-21 18:07:07 -0300 |
---|---|---|
committer | Sergio <sqmedeiros@gmail.com> | 2019-06-21 18:07:07 -0300 |
commit | 0671e873f50ba568074d1683e068d5dce88dd43b (patch) | |
tree | 373f46d1c3fac997803835155a5ba764bbcbd250 /lptree.c | |
parent | 0f48dada44ec37bec8ef1b44ef8b621716ca5c05 (diff) | |
download | lpeglabel-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.c | 18 |
1 files changed, 10 insertions, 8 deletions
@@ -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 | */ |
754 | static TTree *auxemptycap (TTree *tree, int cap) { | 755 | static 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 | */ |
765 | static TTree *newemptycap (lua_State *L, int cap) { | 766 | static 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 | */ |
773 | static TTree *newemptycapkey (lua_State *L, int cap, int idx) { | 776 | static 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 | ||
831 | static int lp_poscapture (lua_State *L) { | 834 | static 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 | ||
837 | static int lp_argcapture (lua_State *L) { | 840 | static 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 | ||