42 |
|
#ifndef SELECTION_TOKEN_HPP |
43 |
|
#define SELECTION_TOKEN_HPP |
44 |
|
|
45 |
+ |
#include <map> |
46 |
+ |
#include <string> |
47 |
+ |
#include <utility> |
48 |
+ |
#include "utils/any.hpp" |
49 |
|
|
50 |
|
namespace oopse { |
51 |
|
|
59 |
|
|
60 |
|
public: |
61 |
|
|
62 |
< |
static std::map<std::string, Token> tokenMap; |
59 |
< |
|
62 |
> |
|
63 |
|
int tok; |
64 |
< |
Object value; |
65 |
< |
int intValue = Integer.MAX_VALUE; |
64 |
> |
boost::any value; |
65 |
> |
int intValue; |
66 |
|
|
67 |
< |
Token(int tok, int intValue, Object value) { |
68 |
< |
this.tok = tok; |
69 |
< |
this.intValue = intValue; |
70 |
< |
this.value = value; |
67 |
> |
Token() { tok = unknown;} |
68 |
> |
|
69 |
> |
Token(const Token& token) { |
70 |
> |
*this = token; |
71 |
|
} |
72 |
+ |
|
73 |
+ |
Token(int tok, int intValue, const boost::any& value) { |
74 |
+ |
this->tok = tok; |
75 |
+ |
this->intValue = intValue; |
76 |
+ |
this->value = value; |
77 |
+ |
} |
78 |
|
|
79 |
|
Token(int tok, int intValue) { |
80 |
< |
this.tok = tok; |
81 |
< |
this.intValue = intValue; |
80 |
> |
this->tok = tok; |
81 |
> |
this->intValue = intValue; |
82 |
|
} |
83 |
|
|
84 |
|
Token(int tok) { |
85 |
< |
this.tok = tok; |
85 |
> |
this->tok = tok; |
86 |
|
} |
87 |
|
|
88 |
< |
Token(int tok, Object value) { |
89 |
< |
this.tok = tok; |
90 |
< |
this.value = value; |
88 |
> |
Token(int tok, const boost::any& value) { |
89 |
> |
this->tok = tok; |
90 |
> |
this->value = value; |
91 |
|
} |
92 |
|
|
93 |
|
const static int nada = 0; |
106 |
|
const static int expressionCommand = (1 << 9); // expression command |
107 |
|
const static int expression = (1 << 10); /// expression term |
108 |
|
|
109 |
+ |
// generally, the minus sign is used to denote atom ranges |
110 |
+ |
// this property is used for the few commands which allow negative integers |
111 |
+ |
const static int negnums = (1 << 11); |
112 |
+ |
|
113 |
+ |
//expression involves coordinates which will change every frame, such as withins |
114 |
+ |
const static int dynamic = (1 << 12); |
115 |
+ |
|
116 |
|
// every property is also valid in an expression context |
117 |
< |
const static int atomproperty = (1 << 11) | expression; |
117 |
> |
const static int atomproperty = (1 << 12) | expression | negnums; |
118 |
|
// every predefined is also valid in an expression context |
119 |
< |
const static int comparator = (1 << 12) | expression; |
120 |
< |
const static int predefinedset = (1 << 13) | expression; |
121 |
< |
|
119 |
> |
const static int comparator = (1 << 13) | expression; |
120 |
> |
const static int predefinedset = (1 << 14) | expression; |
121 |
> |
const static int embeddedExpression= (1 << 15); // embedded expression |
122 |
> |
const static int index = (1 << 16) | expression; |
123 |
|
// rasmol commands |
124 |
|
const static int define = command | expressionCommand |1; |
125 |
|
const static int select = command |expressionCommand |2 ; |
109 |
– |
const static int all = expression | 11 ; |
126 |
|
|
127 |
+ |
//predefine |
128 |
+ |
//const static int selected = predefinedset |0; |
129 |
+ |
|
130 |
|
// atom expression operators |
131 |
|
const static int leftparen = expression | 0; |
132 |
|
const static int rightparen = expression | 1; |
134 |
|
const static int opAnd = expression | 3; |
135 |
|
const static int opOr = expression | 4; |
136 |
|
const static int opNot = expression | 5; |
137 |
< |
const static int within = expression | 6; |
137 |
> |
const static int within = expression | dynamic | 6; |
138 |
|
const static int asterisk = expression | 7; |
139 |
|
const static int dot = expression | 8; |
140 |
< |
|
140 |
> |
const static int all = expression | 9 ; |
141 |
> |
const static int none = expression | 10; |
142 |
> |
const static int name = expression |11; |
143 |
> |
const static int to = expression | 12; |
144 |
|
// miguel 2005 01 01 |
145 |
|
// these are used to demark the beginning and end of expressions |
146 |
|
// they do not exist in the source code, but are emitted by the |
148 |
|
const static int expressionBegin = expression | 100; |
149 |
|
const static int expressionEnd = expression | 101; |
150 |
|
|
151 |
< |
const static int atomno = atomproperty | 0; |
152 |
< |
const static int elemno = atomproperty | 1; |
153 |
< |
const static int resno = atomproperty | 2; |
154 |
< |
const static int radius = atomproperty | 3 ; |
133 |
< |
const static int _bondedcount = atomproperty | 6; |
134 |
< |
const static int _groupID = atomproperty | 7; |
135 |
< |
const static int _atomID = atomproperty | 8; |
136 |
< |
|
151 |
> |
const static int mass = atomproperty | 0; |
152 |
> |
const static int charge = atomproperty | 1; |
153 |
> |
const static int dipole = atomproperty | 2; |
154 |
> |
|
155 |
|
const static int opGT = comparator | 0; |
156 |
|
const static int opGE = comparator | 1; |
157 |
|
const static int opLE = comparator | 2; |
159 |
|
const static int opEQ = comparator | 4; |
160 |
|
const static int opNE = comparator | 5; |
161 |
|
|
162 |
< |
const static int x = expression |2; |
163 |
< |
const static int y = expression | 3; |
146 |
< |
const static int z = expression | 4; |
147 |
< |
const static int none = expression | 5; |
148 |
< |
|
149 |
< |
const static Token tokenExpressionBegin(expressionBegin, "expressionBegin"); |
150 |
< |
const static Token tokenExpressionEnd(expressionEnd, "expressionEnd"); |
162 |
> |
static Token tokenExpressionBegin; |
163 |
> |
static Token tokenExpressionEnd; |
164 |
|
|
152 |
– |
}; |
153 |
– |
|
165 |
|
}; |
166 |
|
|
167 |
|
|
157 |
– |
class TokenMap { |
158 |
– |
const static Object[] arrayPairs = { |
159 |
– |
// commands |
160 |
– |
"define", new Token(define, "define"), |
161 |
– |
"select", new Token(select, "select"), |
162 |
– |
// atom expressions |
163 |
– |
"(", new Token(leftparen, "("), |
164 |
– |
")", new Token(rightparen, ")"), |
165 |
– |
"-", new Token(hyphen, "-"), |
166 |
– |
"and", tokenAnd, |
167 |
– |
"or", new Token(opOr, "or"), |
168 |
– |
"not", new Token(opNot, "not"), |
169 |
– |
"<", new Token(opLT, "<"), |
170 |
– |
"<=", new Token(opLE, "<="), |
171 |
– |
">=", new Token(opGE, ">="), |
172 |
– |
">", new Token(opGT, ">="), |
173 |
– |
"==", new Token(opEQ, "=="), |
174 |
– |
"!=", new Token(opNE, "!="), |
175 |
– |
"within", new Token(within, "within"), |
176 |
– |
".", new Token(dot, "."), |
177 |
– |
"atomno", new Token(atomno, "atomno"), |
178 |
– |
"elemno", tokenElemno, |
179 |
– |
"_bondedcount", new Token(_bondedcount, "_bondedcount"), |
180 |
– |
"_groupID", new Token(_groupID, "_groupID"), |
181 |
– |
"_atomID", new Token(_atomID, "_atomID"), |
182 |
– |
"x", new Token(x, "x"), |
183 |
– |
"y", new Token(y, "y"), |
184 |
– |
"z", new Token(z, "z"), |
185 |
– |
"*", new Token(asterisk, "*"), |
186 |
– |
"all", tokenAll, |
187 |
– |
"none", new Token(none, "none"), |
188 |
– |
|
189 |
– |
}; |
190 |
– |
|
168 |
|
} |
169 |
|
|
170 |
|
#endif |