97 bool compile(
const std::string& filename,
const std::string& script);
99 std::vector<int> getLineNumbers() {
return lineNumbers; }
101 std::vector<int> getLineIndices() {
return lineIndices; }
103 std::vector<std::vector<Token>> getAatokenCompiled() {
104 return aatokenCompiled;
107 std::string getErrorMessage() {
108 std::string strError = errorMessage;
109 strError +=
" : " + errorLine +
"\n";
111 if (!filename.empty()) { strError += filename; }
117 bool internalCompile();
119 bool lookingAtLeadingWhitespace();
121 bool lookingAtEndOfLine();
122 bool lookingAtEndOfStatement();
123 bool lookingAtString();
124 bool lookingAtDecimal(
bool allowNegative);
125 bool lookingAtInteger(
bool allowNegative);
126 bool lookingAtLookupToken();
127 bool lookingAtSpecialString();
129 std::string getUnescapedStringLiteral();
130 int getHexitValue(
char ch);
132 bool compileCommand(
const std::vector<Token>& ltoken);
133 bool compileExpression();
134 bool compileExpression(
int itoken);
139 bool clausePrimitive();
141 bool clauseAlphaHull();
142 bool clauseComparator();
143 bool clauseChemObjName();
146 std::any valuePeek();
149 bool addTokenToPostfix(
const Token& token);
150 bool isNameValid(
const std::string& name);
152 bool compileError(
const std::string& errorMsg) {
153 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
154 "SelectionCompiler Error: %s\n", errorMsg.c_str());
155 painCave.severity = OPENMD_ERROR;
156 painCave.isFatal = 1;
160 this->errorMessage = errorMsg;
164 bool commandExpected() {
return compileError(
"command expected"); }
166 bool invalidExpressionToken(
const std::string& ident) {
167 return compileError(
"invalid expression token:" + ident);
170 bool unrecognizedToken() {
return compileError(
"unrecognized token"); }
172 bool badArgumentCount() {
return compileError(
"bad argument count"); }
174 bool endOfExpressionExpected() {
175 return compileError(
"end of expression expected");
178 bool leftParenthesisExpected() {
179 return compileError(
"left parenthesis expected");
182 bool rightParenthesisExpected() {
183 return compileError(
"right parenthesis expected");
186 bool commaExpected() {
return compileError(
"comma expected"); }
188 bool unrecognizedExpressionToken() {
189 std::any tmp = valuePeek();
190 std::string tokenStr;
193 tokenStr = std::any_cast<std::string>(tmp);
194 }
catch (
const std::bad_any_cast&) {
195 return compileError(
"any_cast error");
198 return compileError(
"unrecognized expression token:" + tokenStr);
201 bool comparisonOperatorExpected() {
202 return compileError(
"comparison operator expected");
205 bool numberExpected() {
return compileError(
"number expected"); }
207 bool numberOrKeywordExpected() {
208 return compileError(
"number or keyword expected");
211 std::string filename;
214 std::vector<int> lineNumbers;
215 std::vector<int> lineIndices;
216 std::vector<std::vector<Token>> aatokenCompiled;
219 std::string errorMessage;
220 std::string errorLine;
227 std::vector<Token> atokenCommand;
229 int ichCurrentCommand;
231 std::vector<Token> ltokenPostfix;
232 std::vector<Token> atokenInfix;
233 std::size_t itokenInfix;