| 10 | } |
| 11 | |
| 12 | double Parser::parse(const char* string, const char* locale) { |
| 13 | DEBUG_PARSER("PARSER: parse('" << string << "') len = " << (int)strlen(string)); |
| 14 | DEBUG_PARSER("********************************"); |
| 15 | |
| 16 | /* be sure that the symbol table has been initialized */ |
| 17 | if (variable_symbols.empty() || static_symbols.empty()) { |
| 18 | init_table(); |
| 19 | } |
| 20 | mLastErrorMessage.clear(); |
| 21 | |
| 22 | param p; |
| 23 | p.locale = locale; |
| 24 | p.parser = this; |
| 25 | p.string = string; |
| 26 | /* pdebug("PARSER: Call yyparse() for \"%s\" (len = %d)\n", p.string, (int)strlen(p.string)); */ |
| 27 | |
| 28 | /* parameter for yylex */ |
| 29 | mResult = NAN; /* default value */ |
| 30 | mParseErrors = 0; /* reset error count */ |
| 31 | yyparse(&p); |
| 32 | |
| 33 | mResult = p.result; |
| 34 | mVariablesCounter = p.variablesCounter; |
| 35 | mParseErrors = p.errorCount; |
| 36 | DEBUG_PARSER("PARSER: parse() DONE (result = " << mResult << ", errors = " << parseErrors() << ")"); |
| 37 | DEBUG_PARSER("*******************************"); |
| 38 | |
| 39 | if (mUsedSymbolsStateMachine == UsedSymbols::Initialize) |
| 40 | mUsedSymbolsStateMachine = UsedSymbols::Only; |
| 41 | |
| 42 | return mResult; |
| 43 | } |
| 44 | |
| 45 | double Parser::parse_with_vars(const char* str, const parser_var* vars, int nvars, const char* locale) { |
| 46 | DEBUG_PARSER("PARSER: parse_with_var('" << str << "') len = " << (int)strlen(str)); |