[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Patch for C++ style comments
- From: "Dan East" <dan@...>
- Date: Fri, 18 Jun 2004 09:21:17 -0400
I hope I am not perceived as Lua heretic for this. :) Here is a very
simple patch that allows C++ style comments // and /* */. My game
engine has a config file system (separate from the lua scripting) that
uses C++ comments. My content creators have already complained about
having to use two different syntaxes so I added the other style comments
to Lua. This does not break the existing Lua comment style - they are
both available after this patch.
Add this case statement to the switch block in llex.c:luaX_lex()
(around line 386):
//Dan East: support for // and /* */ style comments
case '/':
next(LS);
if (LS->current == '/') {
while (LS->current != '\n' && LS->current != EOZ)
next(LS);
continue;
} else if (LS->current == '*') {
next(LS);
while (LS->current != EOZ) {
if (LS->current == '*') {
next(LS);
if (LS->current == '/') {
next(LS);
break;
}
}
next(LS);
}
continue;
} else
return '/';