public static void read_string(LexState LS, int del, SemInfo seminfo)
{
int l = 0;
checkbuffer(LS, l);
save_and_next(LS, ref l);
while (LS.current != del)
{
checkbuffer(LS, l);
switch (LS.current)
{
case EOZ:
save(LS, '\0', ref l);
luaX_lexerror(LS, "unfinished string", (int)RESERVED.TK_EOS);
break; /* to avoid warnings */
case '\n':
case '\r': // lua 5.1 syntax fix
save(LS, '\0', ref l);
luaX_lexerror(LS, "unfinished string", (int)RESERVED.TK_STRING);
break; /* to avoid warnings */
case '\\':
next(LS); /* do not save the `\' */
switch (LS.current)
{
case 'a': save(LS, '\a', ref l); next(LS); break;
case 'b': save(LS, '\b', ref l); next(LS); break;
case 'f': save(LS, '\f', ref l); next(LS); break;
case 'n': save(LS, '\n', ref l); next(LS); break;
case 'r': save(LS, '\r', ref l); next(LS); break;
case 't': save(LS, '\t', ref l); next(LS); break;
case 'v': save(LS, '\v', ref l); next(LS); break;
case '\n':
case '\r': // lua 5.1 syntax fix
save(LS, '\n', ref l); inclinenumber(LS); break;
case EOZ: break; /* will raise an error next loop */
default:
{
if (!(char.IsDigit((char)(LS.current))))
save_and_next(LS, ref l); /* handles \\, \", \', and \? */
else
{ /* \xxx */
int c = 0;
int i = 0;
do
{
c = 10 * c + (LS.current - '0');
next(LS);
} while (++i < 3 && (char.IsDigit((char)(LS.current))));
if (c > UCHAR_MAX)
{
save(LS, '\0', ref l);
luaX_lexerror(LS, "escape sequence too large", (int)RESERVED.TK_STRING);
}
save(LS, (char)c, ref l);
}
break;
}
}
break;
default:
save_and_next(LS, ref l);
break;
}
}
save_and_next(LS, ref l); /* skip delimiter */
save(LS, '\0', ref l);
if (seminfo != null)
{
seminfo.ts = new string(LS.buff, 1, l - 3);
}
}