MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / subexpr

Function subexpr

third-party/lua-5.5.0/src/lparser.c:1374–1401  ·  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

1372** where 'binop' is any binary operator with a priority higher than 'limit'
1373*/
1374static BinOpr subexpr (LexState *ls, expdesc *v, int limit) {
1375 BinOpr op;
1376 UnOpr uop;
1377 enterlevel(ls);
1378 uop = getunopr(ls->t.token);
1379 if (uop != OPR_NOUNOPR) { /* prefix (unary) operator? */
1380 int line = ls->linenumber;
1381 luaX_next(ls); /* skip operator */
1382 subexpr(ls, v, UNARY_PRIORITY);
1383 luaK_prefix(ls->fs, uop, v, line);
1384 }
1385 else simpleexp(ls, v);
1386 /* expand while operators have priorities higher than 'limit' */
1387 op = getbinopr(ls->t.token);
1388 while (op != OPR_NOBINOPR && priority[op].left > limit) {
1389 expdesc v2;
1390 BinOpr nextop;
1391 int line = ls->linenumber;
1392 luaX_next(ls); /* skip operator */
1393 luaK_infix(ls->fs, op, v);
1394 /* read sub-expression with higher priority */
1395 nextop = subexpr(ls, &v2, priority[op].right);
1396 luaK_posfix(ls->fs, op, v, &v2, line);
1397 op = nextop;
1398 }
1399 leavelevel(ls);
1400 return op; /* return first untreated operator */
1401}
1402
1403
1404static void expr (LexState *ls, expdesc *v) {

Callers 1

exprFunction · 0.70

Calls 8

getunoprFunction · 0.70
luaX_nextFunction · 0.70
luaK_prefixFunction · 0.70
simpleexpFunction · 0.70
getbinoprFunction · 0.70
luaK_infixFunction · 0.70
luaK_posfixFunction · 0.70
enterlevelFunction · 0.50

Tested by

no test coverage detected