Skip to content

Commit

Permalink
Runtime Lang Processor ii
Browse files Browse the repository at this point in the history
  • Loading branch information
jmythms committed Mar 19, 2021
1 parent 6a03379 commit 73d0fa0
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 39 deletions.
75 changes: 36 additions & 39 deletions src/EnergyPlus/RuntimeLanguageProcessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1020,9 +1020,6 @@ namespace EnergyPlus::RuntimeLanguageProcessor {
bool LastED; // last character in a numeric was an E or D

// Object Data
static Array1D<TokenType> Token;


CountDoLooping = 0;
NumErrors = 0;
// Error = 'No errors.'
Expand Down Expand Up @@ -1063,7 +1060,7 @@ namespace EnergyPlus::RuntimeLanguageProcessor {
}

// Extend the token array
Token.redimension(++NumTokens);
state.dataRuntimeLangProcessor->PEToken.redimension(++NumTokens);

// Get the next token
StringToken = "";
Expand Down Expand Up @@ -1136,13 +1133,13 @@ namespace EnergyPlus::RuntimeLanguageProcessor {

// Save the number token
if (!ErrorFlag) {
Token(NumTokens).Type = TokenNumber;
Token(NumTokens).String = StringToken;
state.dataRuntimeLangProcessor->PEToken(NumTokens).Type = TokenNumber;
state.dataRuntimeLangProcessor->PEToken(NumTokens).String = StringToken;
if (state.dataSysVars->DeveloperFlag) print(state.files.debug, "Number=\"{}\"\n", StringToken);
Token(NumTokens).Number = UtilityRoutines::ProcessNumber(StringToken, ErrorFlag);
state.dataRuntimeLangProcessor->PEToken(NumTokens).Number = UtilityRoutines::ProcessNumber(StringToken, ErrorFlag);
if (state.dataSysVars->DeveloperFlag && ErrorFlag) print(state.files.debug, "{}\n", "Numeric error flagged");
if (MinusFound) {
Token(NumTokens).Number = -Token(NumTokens).Number;
state.dataRuntimeLangProcessor->PEToken(NumTokens).Number = -state.dataRuntimeLangProcessor->PEToken(NumTokens).Number;
MinusFound = false;
}
if (ErrorFlag) {
Expand Down Expand Up @@ -1177,10 +1174,10 @@ namespace EnergyPlus::RuntimeLanguageProcessor {
}

// Save the variable token
Token(NumTokens).Type = TokenVariable;
Token(NumTokens).String = StringToken;
state.dataRuntimeLangProcessor->PEToken(NumTokens).Type = TokenVariable;
state.dataRuntimeLangProcessor->PEToken(NumTokens).String = StringToken;
if (state.dataSysVars->DeveloperFlag) print(state.files.debug, "Variable=\"{}\"\n", StringToken);
Token(NumTokens).Variable = NewEMSVariable(state, StringToken, StackNum);
state.dataRuntimeLangProcessor->PEToken(NumTokens).Variable = NewEMSVariable(state, StringToken, StackNum);

} else if (is_any_of(NextChar, "+-*/^=<>@|&")) {
// Parse an operator token
Expand Down Expand Up @@ -1211,11 +1208,11 @@ namespace EnergyPlus::RuntimeLanguageProcessor {
DivFound = false;
} else {
StringToken = NextChar;
Token(NumTokens).Type = TokenOperator;
state.dataRuntimeLangProcessor->PEToken(NumTokens).Type = TokenOperator;
}
} else { // any other character process as operator
StringToken = NextChar;
Token(NumTokens).Type = TokenOperator;
state.dataRuntimeLangProcessor->PEToken(NumTokens).Type = TokenOperator;
}

// parse an operator if found,
Expand All @@ -1227,8 +1224,8 @@ namespace EnergyPlus::RuntimeLanguageProcessor {
if ((case_insensitive && UtilityRoutines::SameString(potential_match, string)) ||
(!case_insensitive && potential_match == string)) {
if (state.dataSysVars->DeveloperFlag) print(state.files.debug, "OPERATOR \"{}\"\n", potential_match);
Token(NumTokens).Operator = op;
Token(NumTokens).String = potential_match;
state.dataRuntimeLangProcessor->PEToken(NumTokens).Operator = op;
state.dataRuntimeLangProcessor->PEToken(NumTokens).String = potential_match;
Pos += (len - 1);
return true;
} else {
Expand Down Expand Up @@ -1291,49 +1288,49 @@ namespace EnergyPlus::RuntimeLanguageProcessor {
}
} else {
// Check for remaining single character operators
Token(NumTokens).String = StringToken;
state.dataRuntimeLangProcessor->PEToken(NumTokens).String = StringToken;
MultFound = false;
DivFound = false;

if (state.dataSysVars->DeveloperFlag) print(state.files.debug, "OPERATOR \"{}\"\n", StringToken);

if (StringToken == "+") {
if (!OperatorProcessing) {
Token(NumTokens).Operator = OperatorAdd;
state.dataRuntimeLangProcessor->PEToken(NumTokens).Operator = OperatorAdd;
OperatorProcessing = true;
} else {
PlusFound = true;
OperatorProcessing = false;
}
} else if (StringToken == "-") {
if (!OperatorProcessing) {
Token(NumTokens).Operator = OperatorSubtract;
state.dataRuntimeLangProcessor->PEToken(NumTokens).Operator = OperatorSubtract;
OperatorProcessing = true;
} else {
MinusFound = true;
OperatorProcessing = false;
}
} else if (StringToken == "*") {
Token(NumTokens).Operator = OperatorMultiply;
state.dataRuntimeLangProcessor->PEToken(NumTokens).Operator = OperatorMultiply;
MultFound = true;
OperatorProcessing = true;
} else if (StringToken == "/") {
Token(NumTokens).Operator = OperatorDivide;
state.dataRuntimeLangProcessor->PEToken(NumTokens).Operator = OperatorDivide;
DivFound = true;
OperatorProcessing = true;
} else if (StringToken == "<") {
Token(NumTokens).Operator = OperatorLessThan;
state.dataRuntimeLangProcessor->PEToken(NumTokens).Operator = OperatorLessThan;
OperatorProcessing = true;
} else if (StringToken == ">") {
Token(NumTokens).Operator = OperatorGreaterThan;
state.dataRuntimeLangProcessor->PEToken(NumTokens).Operator = OperatorGreaterThan;
OperatorProcessing = true;
} else if (StringToken == "^") {
Token(NumTokens).Operator = OperatorRaiseToPower;
state.dataRuntimeLangProcessor->PEToken(NumTokens).Operator = OperatorRaiseToPower;
OperatorProcessing = true;
} else if (StringToken == "0" && (NextChar == '-')) {
// process string insert = "0"
Token(NumTokens).Type = TokenNumber;
Token(NumTokens).String = StringToken;
state.dataRuntimeLangProcessor->PEToken(NumTokens).Type = TokenNumber;
state.dataRuntimeLangProcessor->PEToken(NumTokens).String = StringToken;
} else {
// Uh OH, this should never happen! throw error
if (state.dataSysVars->DeveloperFlag) print(state.files.debug, "ERROR \"{}\"\n", StringToken);
Expand All @@ -1348,13 +1345,13 @@ namespace EnergyPlus::RuntimeLanguageProcessor {
++Pos;
StringToken = NextChar;
if (state.dataSysVars->DeveloperFlag) print(state.files.debug, "PAREN \"{}\"\n", StringToken);
Token(NumTokens).Type = TokenParenthesis;
Token(NumTokens).String = StringToken;
state.dataRuntimeLangProcessor->PEToken(NumTokens).Type = TokenParenthesis;
state.dataRuntimeLangProcessor->PEToken(NumTokens).String = StringToken;
if (NextChar == '(') {
Token(NumTokens).Parenthesis = ParenthesisLeft;
state.dataRuntimeLangProcessor->PEToken(NumTokens).Parenthesis = ParenthesisLeft;
OperatorProcessing = true;
}
if (NextChar == ')') Token(NumTokens).Parenthesis = ParenthesisRight;
if (NextChar == ')') state.dataRuntimeLangProcessor->PEToken(NumTokens).Parenthesis = ParenthesisRight;

} else if (is_any_of(NextChar, "\"")) {
// Parse a string literal token
Expand All @@ -1371,7 +1368,7 @@ namespace EnergyPlus::RuntimeLanguageProcessor {
ShowFatalError(state, "EMS, previous errors cause termination.");
}

ExpressionNum = ProcessTokens(state, Token, NumTokens, StackNum, String);
ExpressionNum = ProcessTokens(state, state.dataRuntimeLangProcessor->PEToken, NumTokens, StackNum, String);
}

int ProcessTokens(EnergyPlusData &state, const Array1D<TokenType> &TokenIN, int const NumTokensIN, int const StackNum, std::string const &ParsingString)
Expand Down Expand Up @@ -2494,21 +2491,21 @@ namespace EnergyPlus::RuntimeLanguageProcessor {
int VariableNum(0); // temporary
int RuntimeReportVarNum;
bool Found;
static std::string FreqString; // temporary
static std::string VarTypeString; // temporary
static std::string ResourceTypeString;
static std::string GroupTypeString;
static std::string EndUseTypeString;
static std::string EndUseSubCatString;
std::string FreqString; // temporary
std::string VarTypeString; // temporary
std::string ResourceTypeString;
std::string GroupTypeString;
std::string EndUseTypeString;
std::string EndUseSubCatString;

int TrendNum;
int NumTrendSteps;
int loop;
int ErlVarLoop;
int CurveIndexNum;
static int MaxNumAlphas(0); // argument for call to GetObjectDefMaxArgs
static int MaxNumNumbers(0); // argument for call to GetObjectDefMaxArgs
static int TotalArgs(0); // argument for call to GetObjectDefMaxArgs
int MaxNumAlphas(0); // argument for call to GetObjectDefMaxArgs
int MaxNumNumbers(0); // argument for call to GetObjectDefMaxArgs
int TotalArgs(0); // argument for call to GetObjectDefMaxArgs
Array1D_string cAlphaFieldNames;
Array1D_string cNumericFieldNames;
Array1D_bool lNumericFieldBlanks;
Expand Down
4 changes: 4 additions & 0 deletions src/EnergyPlus/RuntimeLanguageProcessor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ struct RuntimeLanguageProcessorData : BaseGlobalStruct {
std::unordered_map<std::string, std::string> RuntimeReportVarUniqueNames;
bool WriteTraceMyOneTimeFlag = false;

Array1D<RuntimeLanguageProcessor::TokenType> PEToken;

void clear_state() override {
this->AlreadyDidOnce = false;
this->GetInput = true;
Expand Down Expand Up @@ -264,6 +266,8 @@ struct RuntimeLanguageProcessorData : BaseGlobalStruct {
this->ErlStackUniqueNames.clear();
this->RuntimeReportVarUniqueNames.clear();
this->WriteTraceMyOneTimeFlag = false;

this->PEToken.clear();
}
};

Expand Down

5 comments on commit 73d0fa0

@nrel-bot-3
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Global-Psychrometrics (jmythms) - x86_64-MacOS-10.15-clang-11.0.0: OK (3065 of 3065 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Global-Psychrometrics (jmythms) - x86_64-Linux-Ubuntu-18.04-gcc-7.5: OK (3105 of 3105 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2b
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Global-Psychrometrics (jmythms) - x86_64-Linux-Ubuntu-18.04-gcc-7.5-UnitTestsCoverage-Debug: OK (1619 of 1619 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Global-Psychrometrics (jmythms) - Win64-Windows-10-VisualStudio-16: OK (2314 of 2314 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Global-Psychrometrics (jmythms) - x86_64-Linux-Ubuntu-18.04-gcc-7.5-IntegrationCoverage-Debug: OK (726 of 727 tests passed, 0 test warnings)

Failures:\n

integration Test Summary

  • Passed: 726
  • Timeout: 1

Build Badge Test Badge Coverage Badge

Please sign in to comment.