private static void read_long_string(LexState ls, SemInfo seminfo, int sep) { //int cont = 0; //(void)(cont); /* avoid warnings when `cont' is not used */ save_and_next(ls); /* skip 2nd `[' */ if (currIsNewline(ls)) /* string starts with a newline? */ inclinenumber(ls); /* skip it */ for (; ; ) { switch (ls.current) { case EOZ: luaX_lexerror(ls, (seminfo != null) ? "unfinished long string" : "unfinished long comment", (int)RESERVED.TK_EOS); break; /* to avoid warnings */ #if LUA_COMPAT_LSTR case '[': { if (skip_sep(ls) == sep) { save_and_next(ls); /* skip 2nd `[' */ cont++; #if LUA_COMPAT_LSTR if (sep == 0) luaX_lexerror(ls, "nesting of [[...]] is deprecated", '['); #endif } break; } #endif case ']': if (skip_sep(ls) == sep) { save_and_next(ls); /* skip 2nd `]' */ //#if defined(LUA_COMPAT_LSTR) && LUA_COMPAT_LSTR == 2 // cont--; // if (sep == 0 && cont >= 0) break; //#endif goto endloop; } break; case '\n': case '\r': save(ls, '\n'); inclinenumber(ls); if (seminfo == null) luaZ_resetbuffer(ls.buff); /* avoid wasting space */ break; default: { if (seminfo != null) save_and_next(ls); else next(ls); } break; } } endloop: if (seminfo != null) { seminfo.ts = luaX_newstring(ls, luaZ_buffer(ls.buff) + (2 + sep), (uint)(luaZ_bufflen(ls.buff) - 2 * (2 + sep))); } }
/* LUA_NUMBER */ /* ** this function is quite liberal in what it accepts, as 'luaO_str2d' ** will reject ill-formed numerals. */ private static void read_numeral(LexState ls, SemInfo seminfo) { CharPtr expo = new CharPtr("Ee"); int first = ls.current; lua_assert(lisdigit(ls.current)); save_and_next(ls); if (first == '0' && check_next(ls, "Xx") != 0) /* hexadecimal? */ { expo = "Pp"; } for (;;) { if (check_next(ls, expo) != 0) /* exponent part? */ { check_next(ls, "+-"); /* optional exponent sign */ } if (lisxdigit(ls.current) != 0 || ls.current == '.') { save_and_next(ls); } else { break; } } save(ls, '\0'); buffreplace(ls, '.', ls.decpoint); /* follow locale for decimal point */ if (buff2d(ls.buff, out seminfo.r) == 0) /* format error? */ { trydecpoint(ls, seminfo); /* try to update decimal point separator */ } }
public static void read_long_string(LexState ls, SemInfo seminfo, int sep) { int line = ls.linenumber; save_and_next(ls); if (currIsNewline(ls)) { inclinenumber(ls); } while (true) { switch (ls.current) { case EOZ: { string what = (seminfo == null ? "string" : "comment"); string msg = luaO_pushfstring(ls.L, "unfinished long %s (starting at line %d)", what, line); lexerror(ls, msg, (int)RESERVED.TK_EOS); break; } case ']': { if (skip_sep(ls) == sep) { save_and_next(ls); goto endloop; } break; } case '\n': goto case '\r'; case '\r': { save(ls, '\n'); inclinenumber(ls); if (seminfo == null) { luaZ_resetbuffer(ls.buff); } break; } default: { if (seminfo != null) { save_and_next(ls); } else { next(ls); } break; } } } endloop: if (seminfo != null) { seminfo.o = luaX_newstring(ls, luaZ_buffer(ls.buff), 2 + sep, luaZ_bufflen(ls.buff) - 2 * (2 + sep)); } }
private static void read_long_string(LexState ls, SemInfo seminfo, int sep) { save_and_next(ls); /* skip 2nd `[' */ if (currIsNewline(ls)) /* string starts with a newline? */ { inclinenumber(ls); /* skip it */ } for (;;) { switch (ls.current) { case EOZ: lexerror(ls, (seminfo != null) ? "unfinished long string" : "unfinished long comment", (int)RESERVED.TK_EOS); break; /* to avoid warnings */ case ']': { if (skip_sep(ls) == sep) { save_and_next(ls); /* skip 2nd `]' */ goto endloop; } break; } case '\n': case '\r': { save(ls, '\n'); inclinenumber(ls); if (seminfo == null) { luaZ_resetbuffer(ls.buff); /* avoid wasting space */ } break; } default: { if (seminfo != null) { save_and_next(ls); } else { next(ls); } } break; } } endloop: if (seminfo != null) { seminfo.ts = luaX_newstring(ls, luaZ_buffer(ls.buff) + (2 + sep), (uint)(luaZ_bufflen(ls.buff) - 2 * (2 + sep))); } }
/* LUA_NUMBER */ /* ** this function is quite liberal in what it accepts, as 'luaO_str2d' ** will reject ill-formed numerals. 'isf' means the numeral is not ** an integer (it has a dot or an exponent). */ private static int read_numeral(LexState ls, SemInfo seminfo, int isf) { CharPtr expo = new CharPtr("Ee"); int first = ls.current; lua_assert(lisdigit(ls.current)); save_and_next(ls); if (first == '0' && check_next(ls, "Xx") != 0) /* hexadecimal? */ { expo = "Pp"; } for (;;) { if (check_next(ls, expo) != 0) /* exponent part? */ { check_next(ls, "+-"); /* optional exponent sign */ isf = 1; } if (lisxdigit(ls.current) != 0) { save_and_next(ls); } else if (ls.current == '.') { save_and_next(ls); isf = 1; } else { break; } } save(ls, '\0'); if (0 == isf) { if (0 == luaO_str2int(luaZ_buffer(ls.buff), luaZ_bufflen(ls.buff) - 1, ref seminfo.i)) { lexerror(ls, "malformed number", (int)RESERVED.TK_INT); } return((int)RESERVED.TK_INT); } else { buffreplace(ls, '.', ls.decpoint); /* follow locale for decimal point */ if (buff2d(ls.buff, out seminfo.r) == 0) /* format error? */ { trydecpoint(ls, seminfo); /* try to update decimal point separator */ } return((int)RESERVED.TK_FLT); } }
/* LUA_NUMBER */ /* ** this function is quite liberal in what it accepts, as 'luaO_str2num' ** will reject ill-formed numerals. */ public static int read_numeral(LexState ls, SemInfo seminfo) { TValue obj = new TValue(); string expo = "Ee"; int first = ls.current; lua_assert(lisdigit(ls.current)); save_and_next(ls); if (first == '0' && check_next2(ls, "xX")) { expo = "Pp"; } while (true) { if (check_next2(ls, expo)) { check_next2(ls, "-+"); } if (lisxdigit(ls.current)) { save_and_next(ls); } else if (ls.current == '.') { save_and_next(ls); } else { break; } } save(ls, '\0'); buffreplace(ls, (byte)'.', (byte)ls.decpoint); if (buff2num(ls.buff, obj) == false) { trydecpoint(ls, obj); } if (ttisinteger(obj)) { seminfo.o = ivalue(obj); return((int)RESERVED.TK_INT); } else { lua_assert(ttisfloat(obj)); seminfo.o = fltvalue(obj); return((int)RESERVED.TK_FLT); } }
/* LUA_NUMBER */ /* ** this function is quite liberal in what it accepts, as 'luaO_str2num' ** will reject ill-formed numerals. */ private static int read_numeral(LexState ls, SemInfo seminfo) { TValue obj = new TValue(); CharPtr expo = new CharPtr("Ee"); int first = ls.current; lua_assert(lisdigit(ls.current)); save_and_next(ls); if (first == '0' && check_next2(ls, "xX") != 0) /* hexadecimal? */ { expo = "Pp"; } for (;;) { if (check_next2(ls, expo) != 0) /* exponent part? */ { check_next2(ls, "-+"); /* optional exponent sign */ } if (lisxdigit(ls.current) != 0) { save_and_next(ls); } else if (ls.current == '.') { save_and_next(ls); } else { break; } } save(ls, '\0'); buffreplace(ls, '.', ls.decpoint); /* follow locale for decimal point */ if (luaO_str2num(luaZ_buffer(ls.buff), obj) == 0) /* format error? */ { trydecpoint(ls, obj); /* try to update decimal point separator */ } if (ttisinteger(obj)) { seminfo.i = ivalue(obj); return((int)RESERVED.TK_INT); } else { lua_assert(ttisfloat(obj)); seminfo.r = fltvalue(obj); return((int)RESERVED.TK_FLT); } }
private static void trydecpoint(LexState ls, SemInfo seminfo) { /* format error: try to update decimal point separator */ // todo: add proper support for localeconv - mjf //lconv cv = localeconv(); char old = ls.decpoint; ls.decpoint = '.'; // (cv ? cv.decimal_point[0] : '.'); buffreplace(ls, old, ls.decpoint); /* try updated decimal separator */ if (luaO_str2d(luaZ_buffer(ls.buff), out seminfo.r) == 0) { /* format error with correct decimal point: no more options */ buffreplace(ls, ls.decpoint, '.'); /* undo change (for error message) */ luaX_lexerror(ls, "malformed number", (int)RESERVED.TK_NUMBER); } }
/* ** in case of format error, try to change decimal point separator to ** the one defined in the current locale and check again */ private static void trydecpoint(LexState ls, SemInfo seminfo) { // todo: add proper support for localeconv - mjf //lconv cv = localeconv(); //FIXME:???removed??? char old = ls.decpoint; ls.decpoint = getlocaledecpoint(); buffreplace(ls, old, ls.decpoint); /* try new decimal separator */ if (buff2d(ls.buff, out seminfo.r) == 0) { /* format error with correct decimal point: no more options */ buffreplace(ls, ls.decpoint, '.'); /* undo change (for error message) */ lexerror(ls, "malformed number", (int)RESERVED.TK_NUMBER); } }
/* LUA_NUMBER */ private static void read_numeral(LexState ls, SemInfo seminfo) { lua_assert(isdigit(ls.current)); do { save_and_next(ls); } while (isdigit(ls.current) || ls.current == '.'); if (check_next(ls, "EePp") != 0) /* 'E' or 'P'? */ check_next(ls, "+-"); /* optional exponent sign */ while (isalnum(ls.current) || ls.current == '_') save_and_next(ls); save(ls, '\0'); buffreplace(ls, '.', ls.decpoint); /* follow locale for decimal point */ if (luaO_str2d(luaZ_buffer(ls.buff), out seminfo.r) == 0) /* format error? */ trydecpoint(ls, seminfo); /* try to update decimal point separator */ }
/* LUA_NUMBER */ private static void read_numeral(LexState ls, SemInfo seminfo) { lua_assert(lisdigit(ls.current)); do { save_and_next(ls); if (check_next(ls, "EePp") != 0) /* exponent part? */ { check_next(ls, "+-"); /* optional exponent sign */ } } while (lislalnum(ls.current) != 0 || ls.current == '.'); save(ls, '\0'); buffreplace(ls, '.', ls.decpoint); /* follow locale for decimal point */ if (buff2d(ls.buff, out seminfo.r) == 0) /* format error? */ { trydecpoint(ls, seminfo); /* try to update decimal point separator */ } }
/* LUA_NUMBER */ private static void ReadNumeral(LexState ls, SemInfo seminfo) { LuaAssert(isdigit(ls.current)); do { SaveAndNext(ls); } while (isdigit(ls.current) || ls.current == '.'); if (CheckNext(ls, "Ee") != 0) /* `E'? */ { CheckNext(ls, "+-"); /* optional exponent sign */ } while (isalnum(ls.current) || ls.current == '_') { SaveAndNext(ls); } Save(ls, '\0'); BufferReplace(ls, '.', ls.decpoint); /* follow locale for decimal point */ if (LuaOStr2d(luaZ_buffer(ls.buff), out seminfo.r) == 0) /* format error? */ { TryDecPoint(ls, seminfo); /* try to update decimal point separator */ } }
static void read_string(LexState ls, int del, SemInfo seminfo) { save_and_next(ls); while (ls.current != del) { switch (ls.current) { case EOZ: luaX_lexerror(ls, "unfinished string", (int)RESERVED.TK_EOS); continue; /* to avoid warnings */ case '\n': case '\r': luaX_lexerror(ls, "unfinished string", (int)RESERVED.TK_STRING); continue; /* to avoid warnings */ case '\\': { int c; next(ls); /* do not save the `\' */ switch (ls.current) { case 'a': c = '\a'; break; case 'b': c = '\b'; break; case 'f': c = '\f'; break; case 'n': c = '\n'; break; case 'r': c = '\r'; break; case 't': c = '\t'; break; case 'v': c = '\v'; break; case '\n': /* go through */ case '\r': save(ls, '\n'); inclinenumber(ls); continue; case EOZ: continue; /* will raise an error next loop */ default: { if (!isdigit(ls.current)) save_and_next(ls); /* handles \\, \", \', and \? */ else { /* \xxx */ int i = 0; c = 0; do { c = 10*c + (ls.current-'0'); next(ls); } while (++i<3 && isdigit(ls.current)); if (c > System.Byte.MaxValue) luaX_lexerror(ls, "escape sequence too large", (int)RESERVED.TK_STRING); save(ls, c); } continue; } } save(ls, c); next(ls); continue; } default: save_and_next(ls); break; } } save_and_next(ls); /* skip delimiter */ seminfo.ts = luaX_newstring(ls, luaZ_buffer(ls.buff) + 1, luaZ_bufflen(ls.buff) - 2); }
static void read_string(LexState ls, int del, SemInfo seminfo) { save_and_next(ls); while (ls.current != del) { switch (ls.current) { case EOZ: lexerror(ls, "unfinished string", (int)RESERVED.TK_EOS); continue; /* to avoid warnings */ case '\n': case '\r': lexerror(ls, "unfinished string", (int)RESERVED.TK_STRING); continue; /* to avoid warnings */ case '\\': { int c; next(ls); /* do not save the `\' */ switch (ls.current) { case 'a': c = '\a'; break; case 'b': c = '\b'; break; case 'f': c = '\f'; break; case 'n': c = '\n'; break; case 'r': c = '\r'; break; case 't': c = '\t'; break; case 'v': c = '\v'; break; case 'x': c = readhexaesc(ls); break; case '\n': /* go through */ case '\r': save(ls, '\n'); inclinenumber(ls); continue; case EOZ: continue; /* will raise an error next loop */ default: { if (lisdigit(ls.current) == 0) { c = ls.current; /* handles \\, \", \', and \? */ } else /* digital escape \ddd */ { c = readdecesc(ls); } break; } } next(ls); save(ls, c); continue; } default: save_and_next(ls); break; //FIXME:added } } save_and_next(ls); /* skip delimiter */ seminfo.ts = luaX_newstring(ls, luaZ_buffer(ls.buff) + 1, luaZ_bufflen(ls.buff) - 2); }
public static int luaX_lex(LexState LS, SemInfo seminfo) { for (; ; ) { switch (LS.current) { case '\n': case '\r': { inclinenumber(LS); continue; } case '-': { next(LS); if (LS.current != '-') return '-'; /* else is a comment */ next(LS); if (LS.current == '[' && (next(LS) == '[')) { read_long_string(LS, null); /* long comment */ } else {/* short comment */ while (LS.current != '\n' && LS.current != '\r' && LS.current != EOZ) next(LS); } continue; } case '[': { next(LS); if (LS.current != '[') return '['; else { read_long_string(LS, seminfo); return (int)RESERVED.TK_STRING; } } case '=': { next(LS); if (LS.current != '=') return '='; else { next(LS); return (int)RESERVED.TK_EQ; } } case '<': { next(LS); if (LS.current != '=') return '<'; else { next(LS); return (int)RESERVED.TK_LE; } } case '>': { next(LS); if (LS.current != '=') return '>'; else { next(LS); return (int)RESERVED.TK_GE; } } case '~': { next(LS); if (LS.current != '=') return '~'; else { next(LS); return (int)RESERVED.TK_NE; } } case '"': case '\'': { read_string(LS, LS.current, seminfo); return (int)RESERVED.TK_STRING; } case '.': { next(LS); if (LS.current == '.') { next(LS); if (LS.current == '.') { next(LS); return (int)RESERVED.TK_DOTS; /* ... */ } else return (int)RESERVED.TK_CONCAT; /* .. */ } else if (!Char.IsDigit((char)LS.current)) return '.'; else { read_numeral(LS, 1, seminfo); return (int)RESERVED.TK_NUMBER; } } case EOZ: { return (int)RESERVED.TK_EOS; } default: { if (Char.IsWhiteSpace((char)LS.current)) { next(LS); continue; } else if (Char.IsDigit((char)LS.current)) { read_numeral(LS, 0, seminfo); return (int)RESERVED.TK_NUMBER; } else if (char.IsLetter((char)LS.current) || LS.current == '_') { /* identifier or reserved word */ int l = readname(LS); string ts = new string(LS.buff, 0, l); // The following code implemented below //if (ts.tsv.reserved > 0) /* reserved word? */ // return ts.tsv.reserved - 1 + FIRST_RESERVED; /* reserved word? */ for (int i = 0; i < NUM_RESERVED; ++i) { if (ts == token2string[i]) return i + FIRST_RESERVED; } seminfo.ts = ts; return (int)RESERVED.TK_NAME; } else { int c = LS.current; if (Char.IsControl((char)c)) luaX_error(LS, "invalid control char", string.Format("char(0})", c)); next(LS); return c; /* single-char tokens (+ - / ...) */ } //break; } } }//for (;;) { }
private static int llex(LexState ls, SemInfo seminfo) { luaZ_resetbuffer(ls.buff); for (; ;) { switch (ls.current) { case '\n': case '\r': { inclinenumber(ls); continue; } case '-': { next(ls); if (ls.current != '-') { return('-'); } /* else is a comment */ next(ls); if (ls.current == '[') { int sep = skip_sep(ls); luaZ_resetbuffer(ls.buff); /* `skip_sep' may dirty the buffer */ if (sep >= 0) { read_long_string(ls, null, sep); /* long comment */ luaZ_resetbuffer(ls.buff); continue; } } /* else short comment */ while (!currIsNewline(ls) && ls.current != EOZ) { next(ls); } continue; } // EDIT: C-style comments from http://lua-users.org/files/wiki_insecure/power_patches/5.2/cppcomt.diff -- Icedream case '/': { /* '/' or '/''/' (line comment) or '/''*' (long comment) */ next(ls); if (ls.current == '/') { /* line comment */ next(ls); while (!currIsNewline(ls) && ls.current != EOZ) { next(ls); } } else if (ls.current == '*') { /* long comment */ next(ls); int last = 0; while (ls.current != EOZ) { if (last == '*' && ls.current == '/') { break; } last = ls.current; next(ls); /* skip until closing marker (or end of file) */ } if (ls.current == EOZ) { luaX_lexerror(ls, "unfinished long comment", (int)RESERVED.TK_EOS); } else { next(ls); } } else { return('/'); } break; } // END EDIT case '[': { int sep = skip_sep(ls); if (sep >= 0) { read_long_string(ls, seminfo, sep); return((int)RESERVED.TK_STRING); } else if (sep == -1) { return('['); } else { luaX_lexerror(ls, "invalid long string delimiter", (int)RESERVED.TK_STRING); } } break; case '=': { next(ls); if (ls.current != '=') { return('='); } else { next(ls); return((int)RESERVED.TK_EQ); } } case '<': { // either <, <=, or << next(ls); if (ls.current == '=') { next(ls); return((int)RESERVED.TK_LE); } else { return('<'); } } case '>': { // either >, >=, or >> next(ls); if (ls.current == '=') { next(ls); return((int)RESERVED.TK_GE); } else { return('>'); } } case '~': { next(ls); if (ls.current != '=') { return('~'); } else { next(ls); return((int)RESERVED.TK_NE); } } case '"': case '\'': { read_string(ls, ls.current, seminfo); return((int)RESERVED.TK_STRING); } case '.': { save_and_next(ls); if (check_next(ls, ".") != 0) { if (check_next(ls, ".") != 0) { return((int)RESERVED.TK_DOTS); /* ... */ } else { return((int)RESERVED.TK_CONCAT); /* .. */ } } else if (!isdigit(ls.current)) { return('.'); } else { read_numeral(ls, seminfo); return((int)RESERVED.TK_NUMBER); } } case EOZ: { return((int)RESERVED.TK_EOS); } default: { if (isspace(ls.current)) { lua_assert(!currIsNewline(ls)); next(ls); continue; } else if (isdigit(ls.current)) { read_numeral(ls, seminfo); return((int)RESERVED.TK_NUMBER); } else if (isalpha(ls.current) || ls.current == '_') { /* identifier or reserved word */ TString ts; do { save_and_next(ls); } while (isalnum(ls.current) || ls.current == '_'); ts = luaX_newstring(ls, luaZ_buffer(ls.buff), luaZ_bufflen(ls.buff)); if (ts.tsv.reserved > 0) /* reserved word? */ { return(ts.tsv.reserved - 1 + FIRST_RESERVED); } else { seminfo.ts = ts; return((int)RESERVED.TK_NAME); } } else { int c = ls.current; next(ls); return(c); /* single-char tokens (+ - / ...) */ } } } } }
private static int llex(LexState ls, SemInfo seminfo) { luaZ_resetbuffer(ls.buff); for (; ;) { switch (ls.current) { case '\n': case '\r': { inclinenumber(ls); continue; } case '-': { next(ls); if (ls.current != '-') { return('-'); } /* else is a comment */ next(ls); if (ls.current == '[') { int sep = skip_sep(ls); luaZ_resetbuffer(ls.buff); /* `skip_sep' may dirty the buffer */ if (sep >= 0) { read_long_string(ls, null, sep); /* long comment */ luaZ_resetbuffer(ls.buff); continue; } } /* else short comment */ while (!currIsNewline(ls) && ls.current != EOZ) { next(ls); } continue; } case '[': { int sep = skip_sep(ls); if (sep >= 0) { read_long_string(ls, seminfo, sep); return((int)RESERVED.TK_STRING); } else if (sep == -1) { return('['); } else { luaX_lexerror(ls, "invalid long string delimiter", (int)RESERVED.TK_STRING); } } break; case '=': { next(ls); if (ls.current != '=') { return('='); } else { next(ls); return((int)RESERVED.TK_EQ); } } case '<': { next(ls); if (ls.current != '=') { return('<'); } else { next(ls); return((int)RESERVED.TK_LE); } } case '>': { next(ls); if (ls.current != '=') { return('>'); } else { next(ls); return((int)RESERVED.TK_GE); } } case '~': { next(ls); if (ls.current != '=') { return('~'); } else { next(ls); return((int)RESERVED.TK_NE); } } case '"': case '\'': { read_string(ls, ls.current, seminfo); return((int)RESERVED.TK_STRING); } case '.': { save_and_next(ls); if (check_next(ls, ".") != 0) { if (check_next(ls, ".") != 0) { return((int)RESERVED.TK_DOTS); /* ... */ } else { return((int)RESERVED.TK_CONCAT); /* .. */ } } else if (!isdigit(ls.current)) { return('.'); } else { read_numeral(ls, seminfo); return((int)RESERVED.TK_NUMBER); } } case EOZ: { return((int)RESERVED.TK_EOS); } default: { if (isspace(ls.current)) { lua_assert(!currIsNewline(ls)); next(ls); continue; } else if (isdigit(ls.current)) { read_numeral(ls, seminfo); return((int)RESERVED.TK_NUMBER); } else if (isalpha(ls.current) || ls.current == '_') { /* identifier or reserved word */ TString ts; do { save_and_next(ls); } while (isalnum(ls.current) || ls.current == '_'); ts = luaX_newstring(ls, new string( luaZ_buffer(ls.buff).chars, 0, (int)luaZ_bufflen(ls.buff))); if (ts.tsv.reserved > 0) /* reserved word? */ { return(ts.tsv.reserved - 1 + FIRST_RESERVED); } else { seminfo.ts = ts; return((int)RESERVED.TK_NAME); } } else { int c = ls.current; next(ls); return(c); /* single-char tokens (+ - / ...) */ } } } } }
private static int LLex(LexState ls, SemInfo seminfo) { luaZ_resetbuffer(ls.buff); for (;;) { switch (ls.current) { case '\n': case '\r': { IncLineNumber(ls); continue; } case '-': { Next(ls); if (ls.current != '-') { return('-'); } /* else is a comment */ Next(ls); if (ls.current == '[') { int sep = SkipSep(ls); luaZ_resetbuffer(ls.buff); /* `skip_sep' may dirty the buffer */ if (sep >= 0) { ReadLongString(ls, null, sep); /* long comment */ luaZ_resetbuffer(ls.buff); continue; } } /* else short comment */ while (!CurrIsNewline(ls) && ls.current != EOZ) { Next(ls); } continue; } case '[': { int sep = SkipSep(ls); if (sep >= 0) { ReadLongString(ls, seminfo, sep); return((int)RESERVED.TK_STRING); } else if (sep == -1) { return('['); } else { LuaXLexError(ls, "invalid long string delimiter", (int)RESERVED.TK_STRING); } } break; case '=': { Next(ls); if (ls.current != '=') { return('='); } else { Next(ls); return((int)RESERVED.TK_EQ); } } case '<': { Next(ls); if (ls.current != '=') { return('<'); } else { Next(ls); return((int)RESERVED.TK_LE); } } case '>': { Next(ls); if (ls.current != '=') { return('>'); } else { Next(ls); return((int)RESERVED.TK_GE); } } case '~': { Next(ls); if (ls.current != '=') { return('~'); } else { Next(ls); return((int)RESERVED.TK_NE); } } case '"': case '\'': { ReadString(ls, ls.current, seminfo); return((int)RESERVED.TK_STRING); } case '.': { SaveAndNext(ls); if (CheckNext(ls, ".") != 0) { if (CheckNext(ls, ".") != 0) { return((int)RESERVED.TK_DOTS); /* ... */ } else { return((int)RESERVED.TK_CONCAT); /* .. */ } } else if (!isdigit(ls.current)) { return('.'); } else { ReadNumeral(ls, seminfo); return((int)RESERVED.TK_NUMBER); } } case EOZ: { return((int)RESERVED.TK_EOS); } default: { if (isspace(ls.current)) { LuaAssert(!CurrIsNewline(ls)); Next(ls); continue; } else if (isdigit(ls.current)) { ReadNumeral(ls, seminfo); return((int)RESERVED.TK_NUMBER); } else if (isalpha(ls.current) || ls.current == '_') { /* identifier or reserved word */ TString ts; do { SaveAndNext(ls); } while (isalnum(ls.current) || ls.current == '_'); ts = LuaXNewString(ls, luaZ_buffer(ls.buff), luaZ_bufflen(ls.buff)); if (ts.tsv.reserved > 0) /* reserved word? */ { return(ts.tsv.reserved - 1 + FIRSTRESERVED); } else { seminfo.ts = ts; return((int)RESERVED.TK_NAME); } } else { int c = ls.current; Next(ls); return(c); /* single-char tokens (+ - / ...) */ } } } } }
static void read_string(LexState ls, int del, SemInfo seminfo) { save_and_next(ls); /* keep delimiter (for error messages) */ while (ls.current != del) { switch (ls.current) { case EOZ: lexerror(ls, "unfinished string", (int)RESERVED.TK_EOS); break; /* to avoid warnings */ case '\n': case '\r': lexerror(ls, "unfinished string", (int)RESERVED.TK_STRING); break; /* to avoid warnings */ case '\\': { /* escape sequences */ int c; /* final character to be saved */ save_and_next(ls); /* keep '\\' for error messages */ switch (ls.current) { case 'a': c = '\a'; goto read_save; case 'b': c = '\b'; goto read_save; case 'f': c = '\f'; goto read_save; case 'n': c = '\n'; goto read_save; case 'r': c = '\r'; goto read_save; case 't': c = '\t'; goto read_save; case 'v': c = '\v'; goto read_save; case 'x': c = readhexaesc(ls); goto read_save; case 'u': utf8esc(ls); goto no_save; case '\n': case '\r': inclinenumber(ls); c = '\n'; goto only_save; case '\\': case '\"': case '\'': c = ls.current; goto read_save; case EOZ: goto no_save; /* will raise an error next loop */ case 'z': { /* zap following span of spaces */ luaZ_buffremove(ls.buff, 1); /* remove '\\' */ next(ls); /* skip the 'z' */ while (lisspace(ls.current) != 0) { if (currIsNewline(ls)) { inclinenumber(ls); } else { next(ls); } } goto no_save; } default: { esccheck(ls, lisdigit(ls.current), "invalid escape sequence"); c = readdecesc(ls); /* digital escape '\ddd' */ goto only_save; } } read_save: next(ls); /* go through */ only_save: luaZ_buffremove(ls.buff, 1); /* remove '\\' */ save(ls, c); /* go through */ no_save : break; } default: save_and_next(ls); break; //FIXME:added } } save_and_next(ls); /* skip delimiter */ seminfo.ts = luaX_newstring(ls, luaZ_buffer(ls.buff) + 1, luaZ_bufflen(ls.buff) - 2); }
/* LUA_NUMBER */ private static void ReadNumeral(LexState ls, SemInfo seminfo) { LuaAssert(isdigit(ls.current)); do { SaveAndNext(ls); } while (isdigit(ls.current) || ls.current == '.'); if (CheckNext(ls, "Ee") != 0) /* `E'? */ CheckNext(ls, "+-"); /* optional exponent sign */ while (isalnum(ls.current) || ls.current == '_') SaveAndNext(ls); Save(ls, '\0'); BufferReplace(ls, '.', ls.decpoint); /* follow locale for decimal point */ if (LuaOStr2d(luaZ_buffer(ls.buff), out seminfo.r) == 0) /* format error? */ TryDecPoint(ls, seminfo); /* try to update decimal point separator */ }
public Token() { seminfo = new SemInfo(); }
private static int llex(LexState ls, SemInfo seminfo) { luaZ_resetbuffer(ls.buff); for (;;) { switch (ls.current) { case '\n': case '\r': { inclinenumber(ls); continue; } case '-': { next(ls); if (ls.current != '-') return '-'; /* else is a comment */ next(ls); if (ls.current == '[') { int sep = skip_sep(ls); luaZ_resetbuffer(ls.buff); /* `skip_sep' may dirty the buffer */ if (sep >= 0) { read_long_string(ls, null, sep); /* long comment */ luaZ_resetbuffer(ls.buff); continue; } } /* else short comment */ while (!currIsNewline(ls) && ls.current != EOZ) next(ls); continue; } case '[': { int sep = skip_sep(ls); if (sep >= 0) { read_long_string(ls, seminfo, sep); return (int)RESERVED.TK_STRING; } else if (sep == -1) return '['; else luaX_lexerror(ls, "invalid long string delimiter", (int)RESERVED.TK_STRING); } break; case '=': { next(ls); if (ls.current != '=') return '='; else { next(ls); return (int)RESERVED.TK_EQ; } } case '<': { next(ls); if (ls.current != '=') return '<'; else { next(ls); return (int)RESERVED.TK_LE; } } case '>': { next(ls); if (ls.current != '=') return '>'; else { next(ls); return (int)RESERVED.TK_GE; } } case '~': { next(ls); if (ls.current != '=') return '~'; else { next(ls); return (int)RESERVED.TK_NE; } } case '"': case '\'': { read_string(ls, ls.current, seminfo); return (int)RESERVED.TK_STRING; } case '.': { save_and_next(ls); if (check_next(ls, ".") != 0) { if (check_next(ls, ".") != 0) return (int)RESERVED.TK_DOTS; /* ... */ else return (int)RESERVED.TK_CONCAT; /* .. */ } else if (!isdigit(ls.current)) return '.'; else { read_numeral(ls, seminfo); return (int)RESERVED.TK_NUMBER; } } case EOZ: { return (int)RESERVED.TK_EOS; } default: { if (isspace(ls.current)) { lua_assert(!currIsNewline(ls)); next(ls); continue; } else if (isdigit(ls.current)) { read_numeral(ls, seminfo); return (int)RESERVED.TK_NUMBER; } else if (isalpha(ls.current) || ls.current == '_') { /* identifier or reserved word */ TString ts; do { save_and_next(ls); } while (isalnum(ls.current) || ls.current == '_'); ts = luaX_newstring(ls, luaZ_buffer(ls.buff), luaZ_bufflen(ls.buff)); if (ts.tsv.reserved > 0) /* reserved word? */ return ts.tsv.reserved - 1 + FIRST_RESERVED; else { seminfo.ts = ts; return (int)RESERVED.TK_NAME; } } else { int c = ls.current; next(ls); return c; /* single-char tokens (+ - / ...) */ } } } } }
/* LUA_NUMBER */ private static void read_numeral(LexState ls, SemInfo seminfo) { lua_assert(isdigit(ls.current)); do { save_and_next(ls); } while (isdigit(ls.current) || ls.current == '.'); if (check_next(ls, "Ee") != 0) /* `E'? */ check_next(ls, "+-"); /* optional exponent sign */ while (isalnum(ls.current) || ls.current == '_') save_and_next(ls); save(ls, '\0'); buffreplace(ls, '.', ls.decpoint); /* follow locale for decimal point */ if (luaO_str2d(luaZ_buffer(ls.buff), out seminfo.r) == 0) /* format error? */ trydecpoint(ls, seminfo); /* try to update decimal point separator */ }
private static void read_long_string(LexState ls, SemInfo seminfo, int sep) { //int cont = 0; //(void)(cont); /* avoid warnings when `cont' is not used */ save_and_next(ls); /* skip 2nd `[' */ if (currIsNewline(ls)) /* string starts with a newline? */ inclinenumber(ls); /* skip it */ for (;;) { switch (ls.current) { case EOZ: luaX_lexerror(ls, (seminfo != null) ? "unfinished long string" : "unfinished long comment", (int)RESERVED.TK_EOS); break; /* to avoid warnings */ #if LUA_COMPAT_LSTR case '[': { if (skip_sep(ls) == sep) { save_and_next(ls); /* skip 2nd `[' */ cont++; #if LUA_COMPAT_LSTR if (sep == 0) luaX_lexerror(ls, "nesting of [[...]] is deprecated", '['); #endif } break; } #endif case ']': if (skip_sep(ls) == sep) { save_and_next(ls); /* skip 2nd `]' */ //#if defined(LUA_COMPAT_LSTR) && LUA_COMPAT_LSTR == 2 // cont--; // if (sep == 0 && cont >= 0) break; //#endif goto endloop; } break; case '\n': case '\r': save(ls, '\n'); inclinenumber(ls); if (seminfo == null) luaZ_resetbuffer(ls.buff); /* avoid wasting space */ break; default: { if (seminfo != null) save_and_next(ls); else next(ls); } break; } } endloop: if (seminfo != null) { seminfo.ts = luaX_newstring(ls, luaZ_buffer(ls.buff) + (2 + sep), (uint)(luaZ_bufflen(ls.buff) - 2*(2 + sep))); } }
private static void trydecpoint(LexState ls, SemInfo seminfo) { /* format error: try to update decimal point separator */ // todo: add proper support for localeconv - mjf //lconv cv = localeconv(); char old = ls.decpoint; ls.decpoint = '.'; // (cv ? cv.decimal_point[0] : '.'); buffreplace(ls, old, ls.decpoint); /* try updated decimal separator */ if (luaO_str2d(luaZ_buffer(ls.buff), out seminfo.r) == 0) { /* format error with correct decimal point: no more options */ buffreplace(ls, ls.decpoint, '.'); /* undo change (for error message) */ luaX_lexerror(ls, "malformed number", (int)RESERVED.TK_NUMBER); } }
public SemInfo(SemInfo copy) { this.r = copy.r; this.ts = copy.ts; }
} //FIXME:added public SemInfo(SemInfo copy) //FIXME:added { this.r = copy.r; this.ts = copy.ts; }
public Token(Token copy) { this.token = copy.token; this.seminfo = new SemInfo(copy.seminfo); }
private static void read_long_string(LexState ls, SemInfo seminfo, int sep) { int line = ls.linenumber; /* initial line (for error message) */ save_and_next(ls); /* skip 2nd '[' */ if (currIsNewline(ls)) /* string starts with a newline? */ { inclinenumber(ls); /* skip it */ } for (;;) { switch (ls.current) { case EOZ: { /* error */ CharPtr what = (seminfo != null ? "string" : "comment"); CharPtr msg = luaO_pushfstring(ls.L, "unfinished long %s (starting at line %d)", what, line); lexerror(ls, msg, (int)RESERVED.TK_EOS); break; /* to avoid warnings */ } case ']': { if (skip_sep(ls) == sep) { save_and_next(ls); /* skip 2nd ']' */ goto endloop; } break; } case '\n': case '\r': { save(ls, '\n'); inclinenumber(ls); if (seminfo == null) { luaZ_resetbuffer(ls.buff); /* avoid wasting space */ } break; } default: { if (seminfo != null) { save_and_next(ls); } else { next(ls); } } break; } } endloop: if (seminfo != null) { seminfo.ts = luaX_newstring(ls, luaZ_buffer(ls.buff) + (2 + sep), (uint)(luaZ_bufflen(ls.buff) - 2 * (2 + sep))); } }
public static void read_long_string(LexState LS, SemInfo seminfo) { int cont = 0; int l = 0; checkbuffer(LS, l); save(LS, '[', ref l); /* save first `[' */ save_and_next(LS, ref l); /* pass the second `[' */ if (LS.current == '\n' || LS.current == '\r') /* string starts with a newline? */ inclinenumber(LS); /* skip it */ bool bBreak = false; for (; !bBreak; ) { checkbuffer(LS, l); switch (LS.current) { case EOZ: save(LS, '\0', ref l); luaX_lexerror(LS, (seminfo != null) ? "unfinished long string" : "unfinished long comment", (int)RESERVED.TK_EOS); break; /* to avoid warnings */ case '[': save_and_next(LS, ref l); if (LS.current == '[') { cont++; save_and_next(LS, ref l); } continue; case ']': save_and_next(LS, ref l); if (LS.current == ']') { if (cont == 0) bBreak = true; cont--; save_and_next(LS, ref l); } continue; case '\n': case '\r': // lua 5.1 syntax fix save(LS, '\n', ref l); inclinenumber(LS); if (seminfo == null) l = 0; /* reset buffer to avoid wasting space */ continue; default: save_and_next(LS, ref l); break; } } save_and_next(LS, ref l); /* skip the second `]' */ save(LS, '\0', ref l); if (seminfo != null) { seminfo.ts = new string(LS.buff, 2, l - 5); } }
private static int llex(LexState ls, SemInfo seminfo) { luaZ_resetbuffer(ls.buff); for (;;) { switch (ls.current) { case '\n': case '\r': { /* line breaks */ inclinenumber(ls); break; } case ' ': case '\f': case '\t': case '\v': { /* spaces */ next(ls); break; } case '-': { /* '-' or '--' (comment) */ next(ls); if (ls.current != '-') { return('-'); } /* else is a comment */ next(ls); if (ls.current == '[') /* long comment? */ { int sep = skip_sep(ls); luaZ_resetbuffer(ls.buff); /* 'skip_sep' may dirty the buffer */ if (sep >= 0) { read_long_string(ls, null, sep); /* skip long comment */ luaZ_resetbuffer(ls.buff); /* previous call may dirty the buff. */ break; } } /* else short comment */ while (!currIsNewline(ls) && ls.current != EOZ) { next(ls); /* skip until end of line (or end of file) */ } break; } case '[': { /* long string or simply '[' */ int sep = skip_sep(ls); if (sep >= 0) { read_long_string(ls, seminfo, sep); return((int)RESERVED.TK_STRING); } else if (sep != -1) /* '[=...' missing second bracket */ { lexerror(ls, "invalid long string delimiter", (int)RESERVED.TK_STRING); } return('['); } break; case '=': { next(ls); if (0 != check_next1(ls, '=')) { return((int)RESERVED.TK_EQ); } else { return('='); } } case '<': { next(ls); if (0 != check_next1(ls, '=')) { return((int)RESERVED.TK_LE); } else if (0 != check_next1(ls, '<')) { return((int)RESERVED.TK_SHL); } else { return('<'); } } case '>': { next(ls); if (0 != check_next1(ls, '=')) { return((int)RESERVED.TK_GE); } else if (0 != check_next1(ls, '>')) { return((int)RESERVED.TK_SHR); } else { return('>'); } } case '/': { next(ls); if (0 != check_next1(ls, '/')) { return((int)RESERVED.TK_IDIV); } else { return('/'); } } case '~': { next(ls); if (0 != check_next1(ls, '=')) { return((int)RESERVED.TK_NE); } else { return('~'); } } case ':': { next(ls); if (0 != check_next1(ls, ':')) { return((int)RESERVED.TK_DBCOLON); } else { return(':'); } } case '"': case '\'': { /* short literal strings */ read_string(ls, ls.current, seminfo); return((int)RESERVED.TK_STRING); } case '.': { /* '.', '..', '...', or number */ save_and_next(ls); if (0 != check_next1(ls, '.')) { if (0 != check_next1(ls, '.')) { return((int)RESERVED.TK_DOTS); /* '...' */ } else { return((int)RESERVED.TK_CONCAT); /* '..' */ } } else if (0 == lisdigit(ls.current)) { return('.'); } else { return(read_numeral(ls, seminfo)); } } case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { return(read_numeral(ls, seminfo)); } case EOZ: { return((int)RESERVED.TK_EOS); } default: { if (lislalpha(ls.current) != 0) /* identifier or reserved word? */ { TString ts; do { save_and_next(ls); } while (lislalnum(ls.current) != 0); ts = luaX_newstring(ls, luaZ_buffer(ls.buff), luaZ_bufflen(ls.buff)); seminfo.ts = ts; if (isreserved(ts)) /* reserved word? */ { return(ts.extra - 1 + FIRST_RESERVED); } else { return((int)RESERVED.TK_NAME); } } else /* single-char tokens (+ - / ...) */ { int c = ls.current; next(ls); return(c); } } } } }
/* LUA_NUMBER */ 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); } }
static void ReadString(LexState ls, int del, SemInfo seminfo) { SaveAndNext(ls); while (ls.current != del) { switch (ls.current) { case EOZ: LuaXLexError(ls, "unfinished string", (int)RESERVED.TK_EOS); continue; /* to avoid warnings */ case '\n': case '\r': LuaXLexError(ls, "unfinished string", (int)RESERVED.TK_STRING); continue; /* to avoid warnings */ case '\\': { int c; Next(ls); /* do not save the `\' */ switch (ls.current) { case 'a': c = '\a'; break; case 'b': c = '\b'; break; case 'f': c = '\f'; break; case 'n': c = '\n'; break; case 'r': c = '\r'; break; case 't': c = '\t'; break; case 'v': c = '\v'; break; case '\n': /* go through */ case '\r': Save(ls, '\n'); IncLineNumber(ls); continue; case EOZ: continue; /* will raise an error next loop */ default: { if (!isdigit(ls.current)) { SaveAndNext(ls); /* handles \\, \", \', and \? */ } else /* \xxx */ { int i = 0; c = 0; do { c = 10 * c + (ls.current - '0'); Next(ls); } while (++i < 3 && isdigit(ls.current)); if (c > System.Byte.MaxValue) { LuaXLexError(ls, "escape sequence too large", (int)RESERVED.TK_STRING); } Save(ls, c); } continue; } } Save(ls, c); Next(ls); continue; } default: SaveAndNext(ls); break; } } SaveAndNext(ls); /* skip delimiter */ seminfo.ts = LuaXNewString(ls, luaZ_buffer(ls.buff) + 1, luaZ_bufflen(ls.buff) - 2); }
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); } }
static void read_string(LexState ls, int del, SemInfo seminfo) { save_and_next(ls); while (ls.current != del) { switch (ls.current) { case EOZ: luaX_lexerror(ls, "unfinished string", (int)RESERVED.TK_EOS); continue; /* to avoid warnings */ case '\n': case '\r': luaX_lexerror(ls, "unfinished string", (int)RESERVED.TK_STRING); continue; /* to avoid warnings */ case '\\': { int c; next(ls); /* do not save the `\' */ switch (ls.current) { case 'a': c = '\a'; break; case 'b': c = '\b'; break; case 'f': c = '\f'; break; case 'n': c = '\n'; break; case 'r': c = '\r'; break; case 't': c = '\t'; break; case 'v': c = '\v'; break; case '\n': /* go through */ case '\r': save(ls, '\n'); inclinenumber(ls); continue; case EOZ: continue; /* will raise an error next loop */ default: { if (!isdigit(ls.current)) { save_and_next(ls); /* handles \\, \", \', and \? */ } else { /* \xxx */ int i = 0; c = 0; do { c = 10 * c + (ls.current - '0'); next(ls); } while (++i < 3 && isdigit(ls.current)); if (c > System.Byte.MaxValue) { luaX_lexerror(ls, "escape sequence too large", (int)RESERVED.TK_STRING); } save(ls, c); } continue; } } save(ls, c); next(ls); continue; } default: save_and_next(ls); break; } } save_and_next(ls); /* skip delimiter */ seminfo.ts = luaX_newstring(ls, new string( luaZ_buffer(ls.buff).chars, luaZ_buffer(ls.buff).index + 1, (int)(luaZ_bufflen(ls.buff) - 2))); }
public Token(int token_, SemInfo seminfo_) { token = token_; seminfo = seminfo_; }
public SemInfo(SemInfo copy) { this.r = copy.r; this.ts = copy.ts; }
static void read_string(LexState ls, int del, SemInfo seminfo) { save_and_next(ls); /* keep delimiter (for error messages) */ while (ls.current != del) { switch (ls.current) { case EOZ: lexerror(ls, "unfinished string", (int)RESERVED.TK_EOS); break; /* to avoid warnings */ case '\n': case '\r': lexerror(ls, "unfinished string", (int)RESERVED.TK_STRING); break; /* to avoid warnings */ case '\\': { /* escape sequences */ int c; /* final character to be saved */ next(ls); /* do not save the `\' */ switch (ls.current) { case 'a': c = '\a'; break; case 'b': c = '\b'; break; case 'f': c = '\f'; break; case 'n': c = '\n'; break; case 'r': c = '\r'; break; case 't': c = '\t'; break; case 'v': c = '\v'; break; case 'x': c = readhexaesc(ls); break; case '\n': /* go through */ case '\r': save(ls, '\n'); inclinenumber(ls); continue; case '\\': case '\"': case '\'': c = ls.current; break; case EOZ: continue; /* will raise an error next loop */ case 'z': { /* zap following span of spaces */ next(ls); /* skip the 'z' */ while (lisspace(ls.current) != 0) { if (currIsNewline(ls)) { inclinenumber(ls); } else { next(ls); } } continue; /* do not save 'c' */ } default: { if (lisdigit(ls.current) == 0) { escerror(ls, new int[] { ls.current }, 1, "invalid escape sequence"); //FIXME:changed, new int[]{} } /* digital escape \ddd */ c = readdecesc(ls); break; } } next(ls); save(ls, c); break; } default: save_and_next(ls); break; //FIXME:added } } save_and_next(ls); /* skip delimiter */ seminfo.ts = luaX_newstring(ls, luaZ_buffer(ls.buff) + 1, luaZ_bufflen(ls.buff) - 2); }