MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / subexpr

Function subexpr

deps/lua/src/lparser.c:828–853  ·  view source on GitHub ↗

** subexpr -> (simpleexp | unop subexpr) { binop subexpr } ** where `binop' is any binary operator with a priority higher than `limit' */

Source from the content-addressed store, hash-verified

826** where `binop' is any binary operator with a priority higher than `limit'
827*/
828static BinOpr subexpr (LexState *ls, expdesc *v, unsigned int limit) {
829 BinOpr op;
830 UnOpr uop;
831 enterlevel(ls);
832 uop = getunopr(ls->t.token);
833 if (uop != OPR_NOUNOPR) {
834 luaX_next(ls);
835 subexpr(ls, v, UNARY_PRIORITY);
836 luaK_prefix(ls->fs, uop, v);
837 }
838 else simpleexp(ls, v);
839 /* expand while operators have priorities higher than `limit' */
840 op = getbinopr(ls->t.token);
841 while (op != OPR_NOBINOPR && priority[op].left > limit) {
842 expdesc v2;
843 BinOpr nextop;
844 luaX_next(ls);
845 luaK_infix(ls->fs, op, v);
846 /* read sub-expression with higher priority */
847 nextop = subexpr(ls, &v2, priority[op].right);
848 luaK_posfix(ls->fs, op, v, &v2);
849 op = nextop;
850 }
851 leavelevel(ls);
852 return op; /* return first untreated operator */
853}
854
855
856static void expr (LexState *ls, expdesc *v) {

Callers 1

exprFunction · 0.85

Calls 8

enterlevelFunction · 0.85
getunoprFunction · 0.85
luaX_nextFunction · 0.85
luaK_prefixFunction · 0.85
simpleexpFunction · 0.85
getbinoprFunction · 0.85
luaK_infixFunction · 0.85
luaK_posfixFunction · 0.85

Tested by

no test coverage detected