MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / subexpr

Function subexpr

lib/lua/src/lparser.c:1260–1287  ·  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

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