MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / subexpr

Function subexpr

src/Chain/libraries/glua/lparser.cpp:1081–1108  ·  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

1079** where 'binop' is any binary operator with a priority higher than 'limit'
1080*/
1081static BinOpr subexpr(LexState *ls, expdesc *v, int limit) {
1082 BinOpr op;
1083 UnOpr uop;
1084 enterlevel(ls);
1085 uop = getunopr(ls->t.token);
1086 if (uop != OPR_NOUNOPR) {
1087 int line = ls->linenumber;
1088 luaX_next(ls);
1089 subexpr(ls, v, UNARY_PRIORITY);
1090 luaK_prefix(ls->fs, uop, v, line);
1091 }
1092 else simpleexp(ls, v);
1093 /* expand while operators have priorities higher than 'limit' */
1094 op = getbinopr(ls->t.token);
1095 while (op != OPR_NOBINOPR && priority[op].left > limit) {
1096 expdesc v2;
1097 BinOpr nextop;
1098 int line = ls->linenumber;
1099 luaX_next(ls);
1100 luaK_infix(ls->fs, op, v);
1101 /* read sub-expression with higher priority */
1102 nextop = subexpr(ls, &v2, priority[op].right);
1103 luaK_posfix(ls->fs, op, v, &v2, line);
1104 op = nextop;
1105 }
1106 leavelevel(ls);
1107 return op; /* return first untreated operator */
1108}
1109
1110
1111static void expr(LexState *ls, expdesc *v) {

Callers 1

exprFunction · 0.85

Calls 8

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