|
|
@ -22,20 +22,20 @@ bool Compiler::DeclarationParser::parseName (const std::string& name, const Toke
|
|
|
|
char type = mLocals.getType (name2);
|
|
|
|
char type = mLocals.getType (name2);
|
|
|
|
|
|
|
|
|
|
|
|
if (type!=' ')
|
|
|
|
if (type!=' ')
|
|
|
|
{
|
|
|
|
getErrorHandler().warning ("ignoring local variable re-declaration", loc);
|
|
|
|
/// \todo add option to make re-declared local variables an error
|
|
|
|
else
|
|
|
|
getErrorHandler().warning ("ignoring local variable re-declaration",
|
|
|
|
mLocals.declare (mType, name2);
|
|
|
|
loc);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mState = State_End;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mLocals.declare (mType, name2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mState = State_End;
|
|
|
|
mState = State_End;
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (mState==State_End)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
getErrorHandler().warning ("Ignoring extra text after local variable declaration", loc);
|
|
|
|
|
|
|
|
SkipParser skip (getErrorHandler(), getContext());
|
|
|
|
|
|
|
|
scanner.scan (skip);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return Parser::parseName (name, loc, scanner);
|
|
|
|
return Parser::parseName (name, loc, scanner);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -61,17 +61,31 @@ bool Compiler::DeclarationParser::parseKeyword (int keyword, const TokenLoc& loc
|
|
|
|
else if (mState==State_Name)
|
|
|
|
else if (mState==State_Name)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// allow keywords to be used as local variable names. MW script compiler, you suck!
|
|
|
|
// allow keywords to be used as local variable names. MW script compiler, you suck!
|
|
|
|
/// \todo option to disable this atrocity.
|
|
|
|
|
|
|
|
return parseName (loc.mLiteral, loc, scanner);
|
|
|
|
return parseName (loc.mLiteral, loc, scanner);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (mState==State_End)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
getErrorHandler().warning ("Ignoring extra text after local variable declaration", loc);
|
|
|
|
|
|
|
|
SkipParser skip (getErrorHandler(), getContext());
|
|
|
|
|
|
|
|
scanner.scan (skip);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return Parser::parseKeyword (keyword, loc, scanner);
|
|
|
|
return Parser::parseKeyword (keyword, loc, scanner);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Compiler::DeclarationParser::parseSpecial (int code, const TokenLoc& loc, Scanner& scanner)
|
|
|
|
bool Compiler::DeclarationParser::parseSpecial (int code, const TokenLoc& loc, Scanner& scanner)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (code==Scanner::S_newline && mState==State_End)
|
|
|
|
if (mState==State_End)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (code!=Scanner::S_newline)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
getErrorHandler().warning ("Ignoring extra text after local variable declaration", loc);
|
|
|
|
|
|
|
|
SkipParser skip (getErrorHandler(), getContext());
|
|
|
|
|
|
|
|
scanner.scan (skip);
|
|
|
|
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return Parser::parseSpecial (code, loc, scanner);
|
|
|
|
return Parser::parseSpecial (code, loc, scanner);
|
|
|
|
}
|
|
|
|
}
|
|
|
|