|
|
|
@ -190,9 +190,9 @@ namespace Compiler
|
|
|
|
|
popOperator();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExprParser::parseArguments (const std::string& arguments, Scanner& scanner)
|
|
|
|
|
int ExprParser::parseArguments (const std::string& arguments, Scanner& scanner)
|
|
|
|
|
{
|
|
|
|
|
parseArguments (arguments, scanner, mCode);
|
|
|
|
|
return parseArguments (arguments, scanner, mCode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ExprParser::ExprParser (ErrorHandler& errorHandler, Context& context, Locals& locals,
|
|
|
|
@ -210,6 +210,8 @@ namespace Compiler
|
|
|
|
|
|
|
|
|
|
if (mNextOperand)
|
|
|
|
|
{
|
|
|
|
|
start();
|
|
|
|
|
|
|
|
|
|
pushIntegerLiteral (value);
|
|
|
|
|
mTokenLoc = loc;
|
|
|
|
|
return true;
|
|
|
|
@ -231,6 +233,8 @@ namespace Compiler
|
|
|
|
|
|
|
|
|
|
if (mNextOperand)
|
|
|
|
|
{
|
|
|
|
|
start();
|
|
|
|
|
|
|
|
|
|
pushFloatLiteral (value);
|
|
|
|
|
mTokenLoc = loc;
|
|
|
|
|
return true;
|
|
|
|
@ -253,6 +257,8 @@ namespace Compiler
|
|
|
|
|
|
|
|
|
|
if (mNextOperand)
|
|
|
|
|
{
|
|
|
|
|
start();
|
|
|
|
|
|
|
|
|
|
std::string name2 = toLower (name);
|
|
|
|
|
|
|
|
|
|
char type = mLocals.getType (name2);
|
|
|
|
@ -301,6 +307,8 @@ namespace Compiler
|
|
|
|
|
{
|
|
|
|
|
if (keyword==Scanner::K_getdisabled)
|
|
|
|
|
{
|
|
|
|
|
start();
|
|
|
|
|
|
|
|
|
|
mTokenLoc = loc;
|
|
|
|
|
|
|
|
|
|
Generator::getDisabled (mCode, mLiterals, mExplicit);
|
|
|
|
@ -313,6 +321,8 @@ namespace Compiler
|
|
|
|
|
}
|
|
|
|
|
else if (keyword==Scanner::K_getdistance)
|
|
|
|
|
{
|
|
|
|
|
start();
|
|
|
|
|
|
|
|
|
|
mTokenLoc = loc;
|
|
|
|
|
parseArguments ("c", scanner);
|
|
|
|
|
|
|
|
|
@ -333,6 +343,8 @@ namespace Compiler
|
|
|
|
|
|
|
|
|
|
if (extensions->isFunction (keyword, returnType, argumentType, true))
|
|
|
|
|
{
|
|
|
|
|
start();
|
|
|
|
|
|
|
|
|
|
mTokenLoc = loc;
|
|
|
|
|
parseArguments (argumentType, scanner);
|
|
|
|
|
|
|
|
|
@ -354,6 +366,8 @@ namespace Compiler
|
|
|
|
|
{
|
|
|
|
|
if (keyword==Scanner::K_getsquareroot)
|
|
|
|
|
{
|
|
|
|
|
start();
|
|
|
|
|
|
|
|
|
|
mTokenLoc = loc;
|
|
|
|
|
parseArguments ("f", scanner);
|
|
|
|
|
|
|
|
|
@ -365,6 +379,8 @@ namespace Compiler
|
|
|
|
|
}
|
|
|
|
|
else if (keyword==Scanner::K_menumode)
|
|
|
|
|
{
|
|
|
|
|
start();
|
|
|
|
|
|
|
|
|
|
mTokenLoc = loc;
|
|
|
|
|
|
|
|
|
|
Generator::menuMode (mCode);
|
|
|
|
@ -375,6 +391,8 @@ namespace Compiler
|
|
|
|
|
}
|
|
|
|
|
else if (keyword==Scanner::K_random)
|
|
|
|
|
{
|
|
|
|
|
start();
|
|
|
|
|
|
|
|
|
|
mTokenLoc = loc;
|
|
|
|
|
parseArguments ("l", scanner);
|
|
|
|
|
|
|
|
|
@ -386,6 +404,8 @@ namespace Compiler
|
|
|
|
|
}
|
|
|
|
|
else if (keyword==Scanner::K_scriptrunning)
|
|
|
|
|
{
|
|
|
|
|
start();
|
|
|
|
|
|
|
|
|
|
mTokenLoc = loc;
|
|
|
|
|
parseArguments ("c", scanner);
|
|
|
|
|
|
|
|
|
@ -397,6 +417,8 @@ namespace Compiler
|
|
|
|
|
}
|
|
|
|
|
else if (keyword==Scanner::K_getdistance)
|
|
|
|
|
{
|
|
|
|
|
start();
|
|
|
|
|
|
|
|
|
|
mTokenLoc = loc;
|
|
|
|
|
parseArguments ("c", scanner);
|
|
|
|
|
|
|
|
|
@ -408,6 +430,8 @@ namespace Compiler
|
|
|
|
|
}
|
|
|
|
|
else if (keyword==Scanner::K_getsecondspassed)
|
|
|
|
|
{
|
|
|
|
|
start();
|
|
|
|
|
|
|
|
|
|
mTokenLoc = loc;
|
|
|
|
|
|
|
|
|
|
Generator::getSecondsPassed (mCode);
|
|
|
|
@ -418,6 +442,8 @@ namespace Compiler
|
|
|
|
|
}
|
|
|
|
|
else if (keyword==Scanner::K_getdisabled)
|
|
|
|
|
{
|
|
|
|
|
start();
|
|
|
|
|
|
|
|
|
|
mTokenLoc = loc;
|
|
|
|
|
|
|
|
|
|
Generator::getDisabled (mCode, mLiterals, "");
|
|
|
|
@ -431,6 +457,8 @@ namespace Compiler
|
|
|
|
|
// check for custom extensions
|
|
|
|
|
if (const Extensions *extensions = getContext().getExtensions())
|
|
|
|
|
{
|
|
|
|
|
start();
|
|
|
|
|
|
|
|
|
|
char returnType;
|
|
|
|
|
std::string argumentType;
|
|
|
|
|
|
|
|
|
@ -580,6 +608,7 @@ namespace Compiler
|
|
|
|
|
mFirst = true;
|
|
|
|
|
mExplicit.clear();
|
|
|
|
|
mRefOp = false;
|
|
|
|
|
Parser::reset();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char ExprParser::append (std::vector<Interpreter::Type_Code>& code)
|
|
|
|
@ -605,9 +634,12 @@ namespace Compiler
|
|
|
|
|
return mOperands[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExprParser::parseArguments (const std::string& arguments, Scanner& scanner,
|
|
|
|
|
int ExprParser::parseArguments (const std::string& arguments, Scanner& scanner,
|
|
|
|
|
std::vector<Interpreter::Type_Code>& code, bool invert)
|
|
|
|
|
{
|
|
|
|
|
bool optional = false;
|
|
|
|
|
bool optionalCount = 0;
|
|
|
|
|
|
|
|
|
|
ExprParser parser (getErrorHandler(), getContext(), mLocals, mLiterals, true);
|
|
|
|
|
StringParser stringParser (getErrorHandler(), getContext(), mLiterals);
|
|
|
|
|
|
|
|
|
@ -616,12 +648,23 @@ namespace Compiler
|
|
|
|
|
for (std::string::const_iterator iter (arguments.begin()); iter!=arguments.end();
|
|
|
|
|
++iter)
|
|
|
|
|
{
|
|
|
|
|
if (*iter=='S' || *iter=='c')
|
|
|
|
|
if (*iter=='/')
|
|
|
|
|
{
|
|
|
|
|
optional = true;
|
|
|
|
|
}
|
|
|
|
|
else if (*iter=='S' || *iter=='c')
|
|
|
|
|
{
|
|
|
|
|
stringParser.reset();
|
|
|
|
|
|
|
|
|
|
if (optional)
|
|
|
|
|
stringParser.setOptional (true);
|
|
|
|
|
|
|
|
|
|
if (*iter=='c') stringParser.smashCase();
|
|
|
|
|
scanner.scan (stringParser);
|
|
|
|
|
|
|
|
|
|
if (optional && stringParser.isEmpty())
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if (invert)
|
|
|
|
|
{
|
|
|
|
|
std::vector<Interpreter::Type_Code> tmp;
|
|
|
|
@ -631,12 +674,22 @@ namespace Compiler
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
stringParser.append (code);
|
|
|
|
|
|
|
|
|
|
if (optional)
|
|
|
|
|
++optionalCount;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
parser.reset();
|
|
|
|
|
|
|
|
|
|
if (optional)
|
|
|
|
|
parser.setOptional (true);
|
|
|
|
|
|
|
|
|
|
scanner.scan (parser);
|
|
|
|
|
|
|
|
|
|
if (optional && parser.isEmpty())
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
std::vector<Interpreter::Type_Code> tmp;
|
|
|
|
|
|
|
|
|
|
char type = parser.append (tmp);
|
|
|
|
@ -648,6 +701,9 @@ namespace Compiler
|
|
|
|
|
stack.push (tmp);
|
|
|
|
|
else
|
|
|
|
|
std::copy (tmp.begin(), tmp.end(), std::back_inserter (code));
|
|
|
|
|
|
|
|
|
|
if (optional)
|
|
|
|
|
++optionalCount;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -659,6 +715,7 @@ namespace Compiler
|
|
|
|
|
|
|
|
|
|
stack.pop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return optionalCount;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|