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

Function subexpr

third-party/lua-5.4.6/src/lparser.c:1259–1286  ·  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

1257** where 'binop' is any binary operator with a priority higher than 'limit'
1258*/
1259static BinOpr subexpr (LexState *ls, expdesc *v, int limit) {
1260 BinOpr op;
1261 UnOpr uop;
1262 enterlevel(ls);
1263 uop = getunopr(ls->t.token);
1264 if (uop != OPR_NOUNOPR) { /* prefix (unary) operator? */
1265 int line = ls->linenumber;
1266 luaX_next(ls); /* skip operator */
1267 subexpr(ls, v, UNARY_PRIORITY);
1268 luaK_prefix(ls->fs, uop, v, line);
1269 }
1270 else simpleexp(ls, v);
1271 /* expand while operators have priorities higher than 'limit' */
1272 op = getbinopr(ls->t.token);
1273 while (op != OPR_NOBINOPR && priority[op].left > limit) {
1274 expdesc v2;
1275 BinOpr nextop;
1276 int line = ls->linenumber;
1277 luaX_next(ls); /* skip operator */
1278 luaK_infix(ls->fs, op, v);
1279 /* read sub-expression with higher priority */
1280 nextop = subexpr(ls, &v2, priority[op].right);
1281 luaK_posfix(ls->fs, op, v, &v2, line);
1282 op = nextop;
1283 }
1284 leavelevel(ls);
1285 return op; /* return first untreated operator */
1286}
1287
1288
1289static 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