MCPcopy Create free account
hub / github.com/F-Stack/f-stack / subexpr

Function subexpr

freebsd/contrib/openzfs/module/lua/lparser.c:1041–1068  ·  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

1039** where `binop' is any binary operator with a priority higher than `limit'
1040*/
1041static BinOpr subexpr (LexState *ls, expdesc *v, int limit) {
1042 BinOpr op;
1043 UnOpr uop;
1044 enterlevel(ls);
1045 uop = getunopr(ls->t.token);
1046 if (uop != OPR_NOUNOPR) {
1047 int line = ls->linenumber;
1048 luaX_next(ls);
1049 subexpr(ls, v, UNARY_PRIORITY);
1050 luaK_prefix(ls->fs, uop, v, line);
1051 }
1052 else simpleexp(ls, v);
1053 /* expand while operators have priorities higher than `limit' */
1054 op = getbinopr(ls->t.token);
1055 while (op != OPR_NOBINOPR && priority[op].left > limit) {
1056 expdesc v2;
1057 BinOpr nextop;
1058 int line = ls->linenumber;
1059 luaX_next(ls);
1060 luaK_infix(ls->fs, op, v);
1061 /* read sub-expression with higher priority */
1062 nextop = subexpr(ls, &v2, priority[op].right);
1063 luaK_posfix(ls->fs, op, v, &v2, line);
1064 op = nextop;
1065 }
1066 leavelevel(ls);
1067 return op; /* return first untreated operator */
1068}
1069
1070
1071static void expr (LexState *ls, expdesc *v) {

Callers 1

exprFunction · 0.70

Calls 8

enterlevelFunction · 0.70
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

Tested by

no test coverage detected