MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / subexpr

Function subexpr

Source/Misc/lua/src/lua.c:8404–8429  ·  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

8402** where `binop' is any binary operator with a priority higher than `limit'
8403*/
8404static BinOpr subexpr (LexState *ls, expdesc *v, unsigned int limit) {
8405BinOpr op;
8406UnOpr uop;
8407enterlevel(ls);
8408uop = getunopr(ls->t.token);
8409if (uop != OPR_NOUNOPR) {
8410luaX_next(ls);
8411subexpr(ls, v, UNARY_PRIORITY);
8412luaK_prefix(ls->fs, uop, v);
8413}
8414else simpleexp(ls, v);
8415/* expand while operators have priorities higher than `limit' */
8416op = getbinopr(ls->t.token);
8417while (op != OPR_NOBINOPR && priority[op].left > limit) {
8418expdesc v2;
8419BinOpr nextop;
8420luaX_next(ls);
8421luaK_infix(ls->fs, op, v);
8422/* read sub-expression with higher priority */
8423nextop = subexpr(ls, &v2, priority[op].right);
8424luaK_posfix(ls->fs, op, v, &v2);
8425op = nextop;
8426}
8427leavelevel(ls);
8428return op; /* return first untreated operator */
8429}
8430
8431
8432static 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