Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/level/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@

typedef short tokentype;

std::string currentlyRunning = "";

ParserVariables parserVar = {0, 0, 0, 0, {0}, 0, 0};
long lastKeyword = 0;
long lastVariable = 0;
Expand Down Expand Up @@ -515,7 +517,14 @@ void LexRead(LexSymbol *theSymbol) {
if (matchCount > 0) {
std::string s((char *)parserVar.input, matchCount);
theSymbol->kind = kLexConstant;
theSymbol->value.floating = std::stod(s);
double floatResult = 0;
try {
floatResult = std::stod(s);
} catch (...) {
SDL_Log("Parser error: Invalid floating point value: %s", s.c_str());
SDL_Log("In script: '%s'", currentlyRunning.c_str());
}
theSymbol->value.floating = floatResult;
// SDL_Log("\natof(%s) --> %f\n", tempString, theSymbol->value.floating);
parserVar.input += matchCount;
}
Expand Down Expand Up @@ -825,6 +834,7 @@ void ParseStatement(LexSymbol *statement) {
}
}


void SetupCompiler(unsigned char *theInput) {
parserVar.input = theInput;
parserVar.output = NewHandle(1024);
Expand Down Expand Up @@ -970,6 +980,7 @@ char *fixedString(unsigned char *s) {
}

void RunThis(std::string script) {
currentlyRunning = script;
LexSymbol statement;

//char *scriptPtr = (StringPtr)script.c_str();
Expand Down
Loading