disabled escape sequences in script strings (doesn't work with Windows paths)

actorid
Marc Zinnschlag 15 years ago
parent b94e09e030
commit 0d4f2ab3ef

@ -48,35 +48,35 @@ namespace Compiler
switch (mPutback) switch (mPutback)
{ {
case Putback_Special: case Putback_Special:
mPutback = Putback_None; mPutback = Putback_None;
return parser.parseSpecial (mPutbackCode, mPutbackLoc, *this); return parser.parseSpecial (mPutbackCode, mPutbackLoc, *this);
case Putback_Integer: case Putback_Integer:
mPutback = Putback_None; mPutback = Putback_None;
return parser.parseInt (mPutbackInteger, mPutbackLoc, *this); return parser.parseInt (mPutbackInteger, mPutbackLoc, *this);
case Putback_Float: case Putback_Float:
mPutback = Putback_None; mPutback = Putback_None;
return parser.parseFloat (mPutbackFloat, mPutbackLoc, *this); return parser.parseFloat (mPutbackFloat, mPutbackLoc, *this);
case Putback_Name: case Putback_Name:
mPutback = Putback_None; mPutback = Putback_None;
return parser.parseName (mPutbackName, mPutbackLoc, *this); return parser.parseName (mPutbackName, mPutbackLoc, *this);
case Putback_Keyword: case Putback_Keyword:
mPutback = Putback_None; mPutback = Putback_None;
return parser.parseKeyword (mPutbackCode, mPutbackLoc, *this); return parser.parseKeyword (mPutbackCode, mPutbackLoc, *this);
case Putback_None: case Putback_None:
break; break;
} }
char c; char c;
if (!get (c)) if (!get (c))
@ -265,12 +265,12 @@ namespace Compiler
cont = parser.parseName (name, loc, *this); cont = parser.parseName (name, loc, *this);
return true; return true;
} }
int i = 0; int i = 0;
std::string lowerCase; std::string lowerCase;
lowerCase.reserve (name.size()); lowerCase.reserve (name.size());
std::transform (name.begin(), name.end(), std::back_inserter (lowerCase), std::transform (name.begin(), name.end(), std::back_inserter (lowerCase),
(int(*)(int)) std::tolower); (int(*)(int)) std::tolower);
@ -283,13 +283,13 @@ namespace Compiler
cont = parser.parseKeyword (i, loc, *this); cont = parser.parseKeyword (i, loc, *this);
return true; return true;
} }
if (mExtensions) if (mExtensions)
{ {
if (int keyword = mExtensions->searchKeyword (lowerCase)) if (int keyword = mExtensions->searchKeyword (lowerCase))
{ {
cont = parser.parseKeyword (keyword, loc, *this); cont = parser.parseKeyword (keyword, loc, *this);
return true; return true;
} }
} }
@ -316,19 +316,20 @@ namespace Compiler
name += c; name += c;
break; break;
} }
else if (c=='\\') // ignoring escape sequences for now, because they are messing up stupid Windows path names.
{ // else if (c=='\\')
if (!get (c)) // {
{ // if (!get (c))
mErrorHandler.error ("incomplete escape sequence", mLoc); // {
break; // mErrorHandler.error ("incomplete escape sequence", mLoc);
} // break;
} // }
// }
else if (c=='\n') else if (c=='\n')
{ {
mErrorHandler.error ("incomplete string or name", mLoc); mErrorHandler.error ("incomplete string or name", mLoc);
break; break;
} }
} }
else if (!(c=='"' && name.empty())) else if (!(c=='"' && name.empty()))
{ {
@ -341,7 +342,7 @@ namespace Compiler
if (first && std::isdigit (c)) if (first && std::isdigit (c))
error = true; error = true;
} }
name += c; name += c;
first = false; first = false;
} }
@ -374,7 +375,7 @@ namespace Compiler
else else
{ {
putback (c); putback (c);
return false; return false;
} }
} }
else if (c=='!') else if (c=='!')
@ -449,8 +450,8 @@ namespace Compiler
return false; return false;
if (special==S_newline) if (special==S_newline)
mLoc.mLiteral = "<newline>"; mLoc.mLiteral = "<newline>";
TokenLoc loc (mLoc); TokenLoc loc (mLoc);
mLoc.mLiteral.clear(); mLoc.mLiteral.clear();
@ -477,40 +478,39 @@ namespace Compiler
{ {
while (scanToken (parser)); while (scanToken (parser));
} }
void Scanner::putbackSpecial (int code, const TokenLoc& loc) void Scanner::putbackSpecial (int code, const TokenLoc& loc)
{ {
mPutback = Putback_Special; mPutback = Putback_Special;
mPutbackCode = code; mPutbackCode = code;
mPutbackLoc = loc; mPutbackLoc = loc;
} }
void Scanner::putbackInt (int value, const TokenLoc& loc) void Scanner::putbackInt (int value, const TokenLoc& loc)
{ {
mPutback = Putback_Integer; mPutback = Putback_Integer;
mPutbackInteger = value; mPutbackInteger = value;
mPutbackLoc = loc; mPutbackLoc = loc;
} }
void Scanner::putbackFloat (float value, const TokenLoc& loc) void Scanner::putbackFloat (float value, const TokenLoc& loc)
{ {
mPutback = Putback_Float; mPutback = Putback_Float;
mPutbackFloat = value; mPutbackFloat = value;
mPutbackLoc = loc; mPutbackLoc = loc;
} }
void Scanner::putbackName (const std::string& name, const TokenLoc& loc) void Scanner::putbackName (const std::string& name, const TokenLoc& loc)
{ {
mPutback = Putback_Name; mPutback = Putback_Name;
mPutbackName = name; mPutbackName = name;
mPutbackLoc = loc; mPutbackLoc = loc;
} }
void Scanner::putbackKeyword (int keyword, const TokenLoc& loc) void Scanner::putbackKeyword (int keyword, const TokenLoc& loc)
{ {
mPutback = Putback_Keyword; mPutback = Putback_Keyword;
mPutbackCode = keyword; mPutbackCode = keyword;
mPutbackLoc = loc; mPutbackLoc = loc;
} }
} }

Loading…
Cancel
Save