|
39 | 39 |
|
40 | 40 | typedef short tokentype; |
41 | 41 |
|
| 42 | +std::string currentlyRunning = ""; |
| 43 | + |
42 | 44 | ParserVariables parserVar = {0, 0, 0, 0, {0}, 0, 0}; |
43 | 45 | long lastKeyword = 0; |
44 | 46 | long lastVariable = 0; |
@@ -515,7 +517,14 @@ void LexRead(LexSymbol *theSymbol) { |
515 | 517 | if (matchCount > 0) { |
516 | 518 | std::string s((char *)parserVar.input, matchCount); |
517 | 519 | theSymbol->kind = kLexConstant; |
518 | | - theSymbol->value.floating = std::stod(s); |
| 520 | + double floatResult = 0; |
| 521 | + try { |
| 522 | + floatResult = std::stod(s); |
| 523 | + } catch (...) { |
| 524 | + SDL_Log("Parser error: Invalid floating point value: %s", s.c_str()); |
| 525 | + SDL_Log("In script: '%s'", currentlyRunning.c_str()); |
| 526 | + } |
| 527 | + theSymbol->value.floating = floatResult; |
519 | 528 | // SDL_Log("\natof(%s) --> %f\n", tempString, theSymbol->value.floating); |
520 | 529 | parserVar.input += matchCount; |
521 | 530 | } |
@@ -825,6 +834,7 @@ void ParseStatement(LexSymbol *statement) { |
825 | 834 | } |
826 | 835 | } |
827 | 836 |
|
| 837 | + |
828 | 838 | void SetupCompiler(unsigned char *theInput) { |
829 | 839 | parserVar.input = theInput; |
830 | 840 | parserVar.output = NewHandle(1024); |
@@ -970,6 +980,7 @@ char *fixedString(unsigned char *s) { |
970 | 980 | } |
971 | 981 |
|
972 | 982 | void RunThis(std::string script) { |
| 983 | + currentlyRunning = script; |
973 | 984 | LexSymbol statement; |
974 | 985 |
|
975 | 986 | //char *scriptPtr = (StringPtr)script.c_str(); |
|
0 commit comments