public static void read_numeral(LexState LS, int comma, SemInfo seminfo)
{
int l = 0;
checkbuffer(LS, l);
if (comma > 0) save(LS, '.', ref l);
while (Char.IsDigit((char)LS.current))
{
checkbuffer(LS, l);
save_and_next(LS, ref l);
}
if (LS.current == '.')
{
save_and_next(LS, ref l);
if (LS.current == '.')
{
save_and_next(LS, ref l);
save(LS, '\0', ref l);
luaX_lexerror(LS,
"ambiguous syntax (decimal point x string concatenation)",
(int)RESERVED.TK_NUMBER);
}
}
while (Char.IsDigit((char)LS.current))
{
checkbuffer(LS, l);
save_and_next(LS, ref l);
}
if (LS.current == 'e' || LS.current == 'E')
{
save_and_next(LS, ref l); /* read `E' */
if (LS.current == '+' || LS.current == '-')
save_and_next(LS, ref l); /* optional exponent sign */
while (Char.IsDigit((char)LS.current))
{
checkbuffer(LS, l);
save_and_next(LS, ref l);
}
}
save(LS, '\0', ref l);
try
{
seminfo.r = Convert.ToDouble(new string(LS.buff, 0, l - 1));
}
catch (Exception e)
{
luaX_lexerror(LS, "malformed number" + e.ToString(), (int)RESERVED.TK_NUMBER);
}
}