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

Function simpleexp

3rd/lua-5.4.3/src/lparser.c:1128–1180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1126
1127
1128static void simpleexp (LexState *ls, expdesc *v) {
1129 /* simpleexp -> FLT | INT | STRING | NIL | TRUE | FALSE | ... |
1130 constructor | FUNCTION body | suffixedexp */
1131 switch (ls->t.token) {
1132 case TK_FLT: {
1133 init_exp(v, VKFLT, 0);
1134 v->u.nval = ls->t.seminfo.r;
1135 break;
1136 }
1137 case TK_INT: {
1138 init_exp(v, VKINT, 0);
1139 v->u.ival = ls->t.seminfo.i;
1140 break;
1141 }
1142 case TK_STRING: {
1143 codestring(v, ls->t.seminfo.ts);
1144 break;
1145 }
1146 case TK_NIL: {
1147 init_exp(v, VNIL, 0);
1148 break;
1149 }
1150 case TK_TRUE: {
1151 init_exp(v, VTRUE, 0);
1152 break;
1153 }
1154 case TK_FALSE: {
1155 init_exp(v, VFALSE, 0);
1156 break;
1157 }
1158 case TK_DOTS: { /* vararg */
1159 FuncState *fs = ls->fs;
1160 check_condition(ls, fs->f->is_vararg,
1161 "cannot use '...' outside a vararg function");
1162 init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 0, 1));
1163 break;
1164 }
1165 case '{': { /* constructor */
1166 constructor(ls, v);
1167 return;
1168 }
1169 case TK_FUNCTION: {
1170 luaX_next(ls);
1171 body(ls, v, 0, ls->linenumber);
1172 return;
1173 }
1174 default: {
1175 suffixedexp(ls, v);
1176 return;
1177 }
1178 }
1179 luaX_next(ls);
1180}
1181
1182
1183static UnOpr getunopr (int op) {

Callers 1

subexprFunction · 0.85

Calls 6

init_expFunction · 0.85
codestringFunction · 0.85
constructorFunction · 0.85
luaX_nextFunction · 0.85
bodyFunction · 0.85
suffixedexpFunction · 0.85

Tested by

no test coverage detected