# | Line 41 | Line 41 | |
---|---|---|
41 | ||
42 | #ifndef SELECTION_SELECTIONCOMPILER_HPP | |
43 | #define SELECTION_SELECTIONCOMPILER_HPP | |
44 | + | #include <iostream> |
45 | #include <string> | |
46 | #include <vector> | |
47 | + | |
48 | + | #include "selection/Token.hpp" |
49 | + | #include "selection/TokenMap.hpp" |
50 | namespace oopse { | |
51 | ||
52 | ||
# | Line 124 | Line 128 | class SelectionCompiler{ | |
128 | ||
129 | private: | |
130 | ||
131 | < | bool internalcompile(); |
131 | > | bool internalCompile(); |
132 | ||
133 | ||
134 | bool lookingAtLeadingWhitespace(); | |
# | Line 132 | Line 136 | class SelectionCompiler{ | |
136 | bool lookingAtEndOfLine(); | |
137 | bool lookingAtEndOfStatement(); | |
138 | bool lookingAtString(); | |
139 | + | bool lookingAtDecimal(bool allowNegative); |
140 | + | bool lookingAtInteger(bool allowNegative); |
141 | + | bool lookingAtLookupToken(); |
142 | + | bool lookingAtSpecialString(); |
143 | ||
144 | + | std::string getUnescapedStringLiteral(); |
145 | + | int getHexitValue(char ch); |
146 | ||
147 | < | bool compileCommand(const std::vector<vector>&); |
147 | > | bool compileCommand(const std::vector<Token>& ltoken); |
148 | > | bool compileExpression(); |
149 | > | bool compileExpression(int itoken); |
150 | ||
151 | bool clauseOr(); | |
152 | bool clauseAnd(); | |
# | Line 142 | Line 154 | class SelectionCompiler{ | |
154 | bool clausePrimitive(); | |
155 | bool clauseWithin(); | |
156 | bool clauseComparator(); | |
157 | < | bool clauseChemObject(); |
158 | < | bool clauseMolecule(); |
147 | < | bool clauseMolName(); |
148 | < | bool clauseMolIndex(); |
149 | < | bool clauseName(); |
150 | < | bool clauseIndex(); |
151 | < | bool clauseStuntDoubleName(); |
152 | < | bool clauseStuntDoubleIndex(); |
157 | > | bool clauseName(int tok); |
158 | > | bool clauseIndex(int tok); |
159 | ||
160 | + | Token tokenNext(); |
161 | + | boost::any valuePeek(); |
162 | + | int tokPeek(); |
163 | + | |
164 | + | bool addTokenToPostfix(const Token& token); |
165 | + | |
166 | + | |
167 | bool compileError(const std::string& errorMessage) { | |
168 | < | std::cerr << "SelectionCompiler Error: " << errorMessage << << std::endl; |
168 | > | std::cerr << "SelectionCompiler Error: " << errorMessage << std::endl; |
169 | error = true; | |
170 | < | this.errorMessage = errorMessage; |
170 | > | this->errorMessage = errorMessage; |
171 | return false; | |
172 | } | |
173 | ||
# | Line 191 | Line 204 | class SelectionCompiler{ | |
204 | } | |
205 | ||
206 | bool unrecognizedExpressionToken() { | |
207 | < | return compileError("unrecognized expression token:" + valuePeek()); |
207 | > | boost::any tmp = valuePeek(); |
208 | > | std::string tokenStr; |
209 | > | |
210 | > | try { |
211 | > | tokenStr = boost::any_cast<std::string>(tmp); |
212 | > | } catch(const boost::bad_any_cast &) { |
213 | > | return compileError("any_cast error"); |
214 | > | } |
215 | > | |
216 | > | return compileError("unrecognized expression token:" + tokenStr); |
217 | } | |
218 | ||
219 | bool comparisonOperatorExpected() { | |
# | Line 202 | Line 224 | class SelectionCompiler{ | |
224 | return compileError("integer expected"); | |
225 | } | |
226 | ||
227 | + | bool numberOrKeywordExpected() { |
228 | + | return compileError("number or keyword expected"); |
229 | + | } |
230 | ||
231 | std::string filename; | |
232 | std::string script; |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |