diff -burN lua-5.2.0/src/llex.c lua-5.2.0-mod/src/llex.c --- lua-5.2.0/src/llex.c 2011年11月30日 07:43:51 -0500 +++ lua-5.2.0-mod/src/llex.c 2012年01月07日 09:57:11 -0500 @@ -415,6 +415,40 @@ next(ls); /* skip until end of line (or end of file) */ break; } + + /* bn 01/2012: added C++-style comments */ +#if defined(LUA_CPPCOMT_SHORT) || defined(LUA_CPPCOMT_LONG) + case '/': { /* '/' or '/''/' (line comment) or '/''*' (long comment) */ + next(ls); +#if defined(LUA_CPPCOMT_SHORT) + if (ls->current == '/') { + /* line comment */ + next(ls); + while (!currIsNewline(ls) && ls->current != EOZ) + next(ls); /* skip until end of line (or end of file) */ + } else +#endif /* LUA_CPPCOMT_SHORT */ +#if defined(LUA_CPPCOMT_LONG) + 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) + lexerror(ls, "unfinished long comment", TK_EOS); + else next(ls); + } else +#endif /* LUA_CPPCOMT_LONG */ + return '/'; + break; + } +#endif /* LUA_CPPCOMT_SHORT || LUA_CPPCOMT_LONG */ + /* end changes */ + case '[': { /* long string or simply '[' */ int sep = skip_sep(ls); if (sep>= 0) { diff -burN lua-5.2.0/src/llex.h lua-5.2.0-mod/src/llex.h --- lua-5.2.0/src/llex.h 2011年11月30日 07:43:51 -0500 +++ lua-5.2.0-mod/src/llex.h 2012年01月07日 09:57:20 -0500 @@ -15,6 +15,11 @@ +/* bn 01/2012: added C++-style comments */ +#define LUA_CPPCOMT_SHORT +#define LUA_CPPCOMT_LONG +/* end changes */ + /* * WARNING: if you change the order of this enumeration, * grep "ORDER RESERVED"