MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / subexpr

Function subexpr

libraries/AP_Scripting/lua/src/lparser.c:1048–1075  ·  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

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