94 bool compile(
const std::string& filename,
const std::string& script);
96 std::vector<int> getLineNumbers() {
return lineNumbers; }
98 std::vector<int> getLineIndices() {
return lineIndices; }
100 std::vector<std::vector<Token>> getAatokenCompiled() {
101 return aatokenCompiled;
104 std::string getErrorMessage() {
105 std::string strError = errorMessage;
106 strError +=
" : " + errorLine +
"\n";
108 if (!filename.empty()) { strError += filename; }
114 bool internalCompile();
116 bool lookingAtLeadingWhitespace();
118 bool lookingAtEndOfLine();
119 bool lookingAtEndOfStatement();
120 bool lookingAtString();
121 bool lookingAtDecimal(
bool allowNegative);
122 bool lookingAtInteger(
bool allowNegative);
123 bool lookingAtLookupToken();
124 bool lookingAtSpecialString();
126 std::string getUnescapedStringLiteral();
127 int getHexitValue(
char ch);
129 bool compileCommand(
const std::vector<Token>& ltoken);
130 bool compileExpression();
131 bool compileExpression(
int itoken);
136 bool clausePrimitive();
138 bool clauseAlphaHull();
139 bool clauseComparator();
140 bool clauseChemObjName();
143 std::any valuePeek();
146 bool addTokenToPostfix(
const Token& token);
147 bool isNameValid(
const std::string& name);
149 bool compileError(
const std::string& errorMsg) {
150 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
151 "SelectionCompiler Error: %s\n", errorMsg.c_str());
152 painCave.severity = OPENMD_ERROR;
153 painCave.isFatal = 1;
157 this->errorMessage = errorMsg;
161 bool commandExpected() {
return compileError(
"command expected"); }
163 bool invalidExpressionToken(
const std::string& ident) {
164 return compileError(
"invalid expression token:" + ident);
167 bool unrecognizedToken() {
return compileError(
"unrecognized token"); }
169 bool badArgumentCount() {
return compileError(
"bad argument count"); }
171 bool endOfExpressionExpected() {
172 return compileError(
"end of expression expected");
175 bool leftParenthesisExpected() {
176 return compileError(
"left parenthesis expected");
179 bool rightParenthesisExpected() {
180 return compileError(
"right parenthesis expected");
183 bool commaExpected() {
return compileError(
"comma expected"); }
185 bool unrecognizedExpressionToken() {
186 std::any tmp = valuePeek();
187 std::string tokenStr;
190 tokenStr = std::any_cast<std::string>(tmp);
191 }
catch (
const std::bad_any_cast&) {
192 return compileError(
"any_cast error");
195 return compileError(
"unrecognized expression token:" + tokenStr);
198 bool comparisonOperatorExpected() {
199 return compileError(
"comparison operator expected");
202 bool numberExpected() {
return compileError(
"number expected"); }
204 bool numberOrKeywordExpected() {
205 return compileError(
"number or keyword expected");
208 std::string filename;
211 std::vector<int> lineNumbers;
212 std::vector<int> lineIndices;
213 std::vector<std::vector<Token>> aatokenCompiled;
216 std::string errorMessage;
217 std::string errorLine;
224 std::vector<Token> atokenCommand;
226 int ichCurrentCommand;
228 std::vector<Token> ltokenPostfix;
229 std::vector<Token> atokenInfix;
230 std::size_t itokenInfix;