MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / read_numeral

Function read_numeral

source/extern/lua/llex.c:214–243  ·  view source on GitHub ↗

LUA_NUMBER */ ** this function is quite liberal in what it accepts, as 'luaO_str2num' ** will reject ill-formed numerals. */

Source from the content-addressed store, hash-verified

212** will reject ill-formed numerals.
213*/
214static int read_numeral (LexState *ls, SemInfo *seminfo) {
215 TValue obj;
216 const char *expo = "Ee";
217 int first = ls->current;
218 lua_assert(lisdigit(ls->current));
219 save_and_next(ls);
220 if (first == '0' && check_next2(ls, "xX")) /* hexadecimal? */
221 expo = "Pp";
222 for (;;) {
223 if (check_next2(ls, expo)) /* exponent part? */
224 check_next2(ls, "-+"); /* optional exponent sign */
225 if (lisxdigit(ls->current))
226 save_and_next(ls);
227 else if (ls->current == '.')
228 save_and_next(ls);
229 else break;
230 }
231 save(ls, '\0');
232 if (luaO_str2num(luaZ_buffer(ls->buff), &obj) == 0) /* format error? */
233 lexerror(ls, "malformed number", TK_FLT);
234 if (ttisinteger(&obj)) {
235 seminfo->i = ivalue(&obj);
236 return TK_INT;
237 }
238 else {
239 lua_assert(ttisfloat(&obj));
240 seminfo->r = fltvalue(&obj);
241 return TK_FLT;
242 }
243}
244
245
246/*

Callers 1

llexFunction · 0.85

Calls 4

check_next2Function · 0.85
saveFunction · 0.85
luaO_str2numFunction · 0.85
lexerrorFunction · 0.85

Tested by

no test coverage detected