MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / subexpr

Function subexpr

extlibs/lua/src/lparser.c:1241–1268  ·  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

1239** where 'binop' is any binary operator with a priority higher than 'limit'
1240*/
1241static BinOpr subexpr (LexState *ls, expdesc *v, int limit) {
1242 BinOpr op;
1243 UnOpr uop;
1244 enterlevel(ls);
1245 uop = getunopr(ls->t.token);
1246 if (uop != OPR_NOUNOPR) { /* prefix (unary) operator? */
1247 int line = ls->linenumber;
1248 luaX_next(ls); /* skip operator */
1249 subexpr(ls, v, UNARY_PRIORITY);
1250 luaK_prefix(ls->fs, uop, v, line);
1251 }
1252 else simpleexp(ls, v);
1253 /* expand while operators have priorities higher than 'limit' */
1254 op = getbinopr(ls->t.token);
1255 while (op != OPR_NOBINOPR && priority[op].left > limit) {
1256 expdesc v2;
1257 BinOpr nextop;
1258 int line = ls->linenumber;
1259 luaX_next(ls); /* skip operator */
1260 luaK_infix(ls->fs, op, v);
1261 /* read sub-expression with higher priority */
1262 nextop = subexpr(ls, &v2, priority[op].right);
1263 luaK_posfix(ls->fs, op, v, &v2, line);
1264 op = nextop;
1265 }
1266 leavelevel(ls);
1267 return op; /* return first untreated operator */
1268}
1269
1270
1271static void expr (LexState *ls, expdesc *v) {

Callers 1

exprFunction · 0.85

Calls 7

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