ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-3.0/src/selection/Token.hpp
(Generate patch)

Comparing trunk/OOPSE-3.0/src/selection/Token.hpp (file contents):
Revision 1962 by tim, Tue Feb 1 22:49:23 2005 UTC vs.
Revision 1965 by tim, Wed Feb 2 23:13:11 2005 UTC

# Line 42 | Line 42
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  
# Line 55 | Line 59 | class Token {
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;
# Line 97 | Line 106 | class Token {
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          // every property is also valid in an expression context
114 <        const static int atomproperty      = (1 << 11) | expression;
114 >        const static int atomproperty      = (1 << 12) | expression | negnums;
115          // every predefined is also valid in an expression context
116 <        const static int comparator        = (1 << 12) | expression;
117 <        const static int predefinedset     = (1 << 13) | expression;
118 <
116 >        const static int comparator        = (1 << 13) | expression;
117 >        const static int predefinedset     = (1 << 14) | expression;
118 >        const  static int embeddedExpression= (1 << 15); // embedded expression
119 >        
120          // rasmol commands
121          const static int define       = command | expressionCommand |1;
122          const static int select       = command |expressionCommand |2 ;
109        const static int all          = expression | 11 ;
123  
124 +        //predefine
125 +        const static int selected    = predefinedset |0;
126 +
127          // atom expression operators
128          const static int leftparen    = expression |  0;
129          const static int rightparen   = expression |  1;
# Line 118 | Line 134 | class Token {
134          const static int within       = expression |  6;
135          const static int asterisk     = expression |  7;
136          const static int dot          = expression | 8;
137 <
137 >        const static int name            =  expression |9;
138 >        const static int index            =  expression | 10;
139 >        const static int molname            =  expression | 11;
140 >        const static int molindex      =  expression | 12;
141 >        const static int all          = expression | 13 ;
142 >        const static int none      = expression | 14;
143 >        
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
# Line 126 | Line 148 | class Token {
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;
# Line 141 | Line 159 | class Token {
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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines