MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / subexpr

Function subexpr

3rd/lua-5.4.3/src/lparser.c:1248–1275  ·  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

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