77 bool loadScriptString(
const std::string& script);
78 bool loadScriptFile(
const std::string& filename);
88 bool hadRuntimeError()
const {
return error; }
90 std::string getErrorMessage()
const {
return errorMessage; }
92 int getLinenumber() {
return linenumbers[pc]; }
94 std::string getLine() {
95 std::size_t ichBegin = lineIndices[pc];
97 if ((ichEnd = script.find(
'\r', ichBegin)) == std::string::npos &&
98 (ichEnd = script.find(
'\n', ichBegin)) == std::string::npos) {
99 ichEnd = script.size();
101 return script.substr(ichBegin, ichEnd);
103 bool hasSurfaceArea() {
return hasSurfaceArea_; }
104 RealType getSurfaceArea() {
105 if (hasSurfaceArea_) {
108 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
109 "SelectionEvaluator Error: %s\n",
"No Surface Area For You!");
110 painCave.severity = OPENMD_ERROR;
111 painCave.isFatal = 1;
116 bool hasVolume() {
return hasVolume_; }
117 RealType getVolume() {
121 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
122 "SelectionEvaluator Error: %s\n",
"No Volume For You!");
123 painCave.severity = OPENMD_ERROR;
124 painCave.isFatal = 1;
133 bool loadScript(
const std::string& filename,
const std::string& script);
135 bool loadScriptFileInternal(
const std::string& filename);
137 SelectionSet createSelectionSets();
138 void clearDefinitionsAndLoadPredefined();
141 void select(SelectionSet& bs);
142 void select(SelectionSet& bs,
int frame);
143 void predefine(
const std::string& script);
145 void instructionDispatchLoop(SelectionSet& bs);
146 void instructionDispatchLoop(SelectionSet& bs,
int frame);
148 void withinInstruction(
const Token& instruction, SelectionSet& bs);
149 void withinInstruction(
const Token& instruction, SelectionSet& bs,
152 SelectionSet alphaHullInstruction(
const Token& instruction);
153 SelectionSet alphaHullInstruction(
const Token& instruction,
int frame);
155 SelectionSet allInstruction();
157 SelectionSet comparatorInstruction(
const Token& instruction);
158 SelectionSet comparatorInstruction(
const Token& instruction,
int frame);
159 void compareProperty(StuntDouble* sd, SelectionSet& bs,
int property,
160 int comparator,
float comparisonValue);
161 void compareProperty(StuntDouble* sd, SelectionSet& bs,
int property,
162 int comparator,
float comparisonValue,
int frame);
163 void compareProperty(Molecule* mol, SelectionSet& bs,
int property,
164 int comparator,
float comparisonValue);
165 void compareProperty(Molecule* mol, SelectionSet& bs,
int property,
166 int comparator,
float comparisonValue,
int frame);
167 SelectionSet nameInstruction(
const std::string& name);
168 SelectionSet indexInstruction(
const std::any& value);
169 SelectionSet expression(
const std::vector<Token>& tokens,
int pc);
170 SelectionSet expression(
const std::vector<Token>& tokens,
int pc,
173 SelectionSet lookupValue(
const std::string& variable);
176 SelectionSet hull(
int frame);
178 void evalError(
const std::string& message) {
179 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
180 "SelectionEvaluator Error: %s\n", message.c_str());
181 painCave.severity = OPENMD_ERROR;
182 painCave.isFatal = 1;
186 void unrecognizedCommand(
const Token& token) {
187 evalError(
"unrecognized command:" +
188 std::any_cast<std::string>(token.value));
191 void unrecognizedExpression() { evalError(
"unrecognized expression"); }
193 void unrecognizedAtomProperty(
int) {
194 evalError(
"unrecognized atom property");
197 void unrecognizedMoleculeProperty(
int) {
198 evalError(
"unrecognized molecule property");
201 void unrecognizedIdentifier(
const std::string& identifier) {
202 evalError(
"unrecognized identifier:" + identifier);
205 void invalidIndexRange(std::pair<int, int> range) {
206 evalError(
"invalid index range: [" +
toString(range.first) +
", " +
210 void invalidIndex(
int index) {
211 evalError(
"invalid index : " +
toString(index));
214 bool containDynamicToken(
const std::vector<Token>& tokens);
216 RealType getCharge(Atom* atom);
217 RealType getCharge(Atom* atom,
int frame);
219 SelectionCompiler compiler;
226 std::string filename;
228 std::vector<int> linenumbers;
229 std::vector<int> lineIndices;
230 std::vector<std::vector<Token>> aatoken;
234 std::string errorMessage;
236 std::vector<Token> statement;
239 SimInfo* info {
nullptr};
240 NameFinder nameFinder;
241 DistanceFinder distanceFinder;
242 HullFinder hullFinder;
243 AlphaHullFinder alphaHullFinder;
244 IndexFinder indexFinder;
245 vector<int> nObjects;
247 using VariablesType = std::map<std::string, std::any>;
248 VariablesType variables;
250 bool isDynamic_ {
false};
251 bool isLoaded_ {
false};
252 bool hasSurfaceArea_ {
false};
253 RealType surfaceArea_;
254 bool hasVolume_ {
false};