Token.hpp
Go to the documentation of this file.
1 /*----------------------------------------------------------------------------*/
2 /* */
3 /* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */
4 /* Copyright (c) 2005-2009 Rexx Language Association. All rights reserved. */
5 /* */
6 /* This program and the accompanying materials are made available under */
7 /* the terms of the Common Public License v1.0 which accompanies this */
8 /* distribution. A copy is also available at the following address: */
9 /* http://www.oorexx.org/license.html */
10 /* */
11 /* Redistribution and use in source and binary forms, with or */
12 /* without modification, are permitted provided that the following */
13 /* conditions are met: */
14 /* */
15 /* Redistributions of source code must retain the above copyright */
16 /* notice, this list of conditions and the following disclaimer. */
17 /* Redistributions in binary form must reproduce the above copyright */
18 /* notice, this list of conditions and the following disclaimer in */
19 /* the documentation and/or other materials provided with the distribution. */
20 /* */
21 /* Neither the name of Rexx Language Association nor the names */
22 /* of its contributors may be used to endorse or promote products */
23 /* derived from this software without specific prior written permission. */
24 /* */
25 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
26 /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
27 /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
28 /* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
29 /* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
30 /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
31 /* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
32 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */
33 /* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
34 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
35 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
36 /* */
37 /*----------------------------------------------------------------------------*/
38 /******************************************************************************/
39 /* REXX Kernel */
40 /* */
41 /* Primitive Translator Token Class Definitions */
42 /* */
43 /******************************************************************************/
44 #ifndef Included_RexxToken
45 #define Included_RexxToken
46 
47 #include "SourceLocation.hpp"
48 
49 #define REFINE_SUBCLASS
50 #ifdef REFINE_SUBCLASS
51 #define refineSubclass(token, refinedSubclass) {token->subclass = refinedSubclass;}
52 #else
53 #define refineSubclass(token, subclass) {}
54 #endif
55 
56 #define TERM_EOC 0x00000001u /* terminate on end of clause */
57 #define TERM_RIGHT 0x00000002u /* terminate on left paren */
58 #define TERM_SQRIGHT 0x00000004u /* terminate on left square bracket */
59 #define TERM_TO 0x00000008u /* terminate on TO keyword */
60 #define TERM_BY 0x00000010u /* terminate on BY keyword */
61 #define TERM_FOR 0x00000020u /* terminate on FOR keyword */
62 #define TERM_WHILE 0x00000040u /* terminate on WHILE/UNTIL keywords */
63 #define TERM_COMMA 0x00000080u /* terminate on comma */
64 #define TERM_WITH 0x00000100u /* terminate on WITH keyword */
65 #define TERM_THEN 0x00000200u /* terminate on THEN keyword */
66 #define TERM_KEYWORD 0x10000000u /* perform keyword terminator checks */
67  /* terminate on DO keywords */
68 #define TERM_CONTROL (TERM_KEYWORD | TERM_TO | TERM_BY | TERM_FOR | TERM_WHILE | TERM_EOC)
69  /* terminate on DO conditionals */
70 #define TERM_COND (TERM_KEYWORD | TERM_WHILE | TERM_EOC)
71 
72 #define TERM_IF (TERM_KEYWORD | TERM_THEN | TERM_EOC)
73 
74 /* token types */
75 typedef int TokenClass;
76 #define TOKEN_NULL 1201
77 #define TOKEN_BLANK TOKEN_NULL + 1
78 #define TOKEN_SYMBOL TOKEN_BLANK + 1
79 #define TOKEN_LITERAL TOKEN_SYMBOL + 1
80 #define TOKEN_OPERATOR TOKEN_LITERAL + 1
81 #define TOKEN_EOC TOKEN_OPERATOR + 1
82 #define TOKEN_COMMA TOKEN_EOC + 1
83 #define TOKEN_PREFIX TOKEN_COMMA + 1
84 #define TOKEN_LEFT TOKEN_PREFIX + 1
85 #define TOKEN_RIGHT TOKEN_LEFT + 1
86 #define TOKEN_POINT TOKEN_RIGHT + 1
87 #define TOKEN_COLON TOKEN_POINT + 1
88 #define TOKEN_TILDE TOKEN_COLON + 1
89 #define TOKEN_DTILDE TOKEN_TILDE + 1
90 #define TOKEN_SQLEFT TOKEN_DTILDE + 1
91 #define TOKEN_SQRIGHT TOKEN_SQLEFT + 1
92 #define TOKEN_DCOLON TOKEN_SQRIGHT + 1
93 #define TOKEN_CONTINUE TOKEN_DCOLON + 1
94 #define TOKEN_ASSIGNMENT TOKEN_CONTINUE + 1
95 #define TOKEN_SOURCE_LITERAL TOKEN_ASSIGNMENT+ 1
96 
97 /* token extended types - symbols */
98 #define SYMBOL_CONSTANT 1251
99 #define SYMBOL_VARIABLE 1252
100 #define SYMBOL_NAME 1253
101 #define SYMBOL_COMPOUND 1254
102 #define SYMBOL_STEM 1255
103 #define SYMBOL_DUMMY 1256
104 #define SYMBOL_DOTSYMBOL 1257
105 #define INTEGER_CONSTANT 1258
106 #define LITERAL_HEX 1259
107 #define LITERAL_BIN 1260
108 
109 /* token extended types - operators */
110 #define OPERATOR_PLUS 1
111 #define OPERATOR_SUBTRACT OPERATOR_PLUS + 1
112 #define OPERATOR_MULTIPLY OPERATOR_SUBTRACT + 1
113 #define OPERATOR_DIVIDE OPERATOR_MULTIPLY + 1
114 #define OPERATOR_INTDIV OPERATOR_DIVIDE + 1
115 #define OPERATOR_REMAINDER OPERATOR_INTDIV + 1
116 #define OPERATOR_POWER OPERATOR_REMAINDER + 1
117 #define OPERATOR_ABUTTAL OPERATOR_POWER + 1
118 #define OPERATOR_CONCATENATE OPERATOR_ABUTTAL + 1
119 #define OPERATOR_BLANK OPERATOR_CONCATENATE + 1
120 #define OPERATOR_EQUAL OPERATOR_BLANK + 1
121 #define OPERATOR_BACKSLASH_EQUAL OPERATOR_EQUAL + 1
122 #define OPERATOR_GREATERTHAN OPERATOR_BACKSLASH_EQUAL + 1
123 #define OPERATOR_BACKSLASH_GREATERTHAN OPERATOR_GREATERTHAN + 1
124 #define OPERATOR_LESSTHAN OPERATOR_BACKSLASH_GREATERTHAN + 1
125 #define OPERATOR_BACKSLASH_LESSTHAN OPERATOR_LESSTHAN + 1
126 #define OPERATOR_GREATERTHAN_EQUAL OPERATOR_BACKSLASH_LESSTHAN + 1
127 #define OPERATOR_LESSTHAN_EQUAL OPERATOR_GREATERTHAN_EQUAL + 1
128 #define OPERATOR_STRICT_EQUAL OPERATOR_LESSTHAN_EQUAL + 1
129 #define OPERATOR_STRICT_BACKSLASH_EQUAL OPERATOR_STRICT_EQUAL + 1
130 #define OPERATOR_STRICT_GREATERTHAN OPERATOR_STRICT_BACKSLASH_EQUAL + 1
131 #define OPERATOR_STRICT_BACKSLASH_GREATERTHAN OPERATOR_STRICT_GREATERTHAN + 1
132 #define OPERATOR_STRICT_LESSTHAN OPERATOR_STRICT_BACKSLASH_GREATERTHAN + 1
133 #define OPERATOR_STRICT_BACKSLASH_LESSTHAN OPERATOR_STRICT_LESSTHAN + 1
134 #define OPERATOR_STRICT_GREATERTHAN_EQUAL OPERATOR_STRICT_BACKSLASH_LESSTHAN + 1
135 #define OPERATOR_STRICT_LESSTHAN_EQUAL OPERATOR_STRICT_GREATERTHAN_EQUAL + 1
136 #define OPERATOR_LESSTHAN_GREATERTHAN OPERATOR_STRICT_LESSTHAN_EQUAL + 1
137 #define OPERATOR_GREATERTHAN_LESSTHAN OPERATOR_LESSTHAN_GREATERTHAN + 1
138 #define OPERATOR_AND OPERATOR_GREATERTHAN_LESSTHAN + 1
139 #define OPERATOR_OR OPERATOR_AND + 1
140 #define OPERATOR_XOR OPERATOR_OR + 1
141 #define OPERATOR_BACKSLASH OPERATOR_XOR + 1
142 
143 
144 /* token extended types - instruction keywords */
145 #define IS_KEYWORD 2100 // refinedtoken subclass
146 #define KEYWORD_ADDRESS 1
147 #define KEYWORD_ARG KEYWORD_ADDRESS + 1
148 #define KEYWORD_CALL KEYWORD_ARG + 1
149 #define KEYWORD_DO KEYWORD_CALL + 1
150 #define KEYWORD_DROP KEYWORD_DO + 1
151 #define KEYWORD_EXIT KEYWORD_DROP + 1
152 #define KEYWORD_IF KEYWORD_EXIT + 1
153 #define KEYWORD_INTERPRET KEYWORD_IF + 1
154 #define KEYWORD_ITERATE KEYWORD_INTERPRET + 1
155 #define KEYWORD_LEAVE KEYWORD_ITERATE + 1
156 #define KEYWORD_METHOD KEYWORD_LEAVE + 1
157 #define KEYWORD_NOP KEYWORD_METHOD + 1
158 #define KEYWORD_NUMERIC KEYWORD_NOP + 1
159 #define KEYWORD_OPTIONS KEYWORD_NUMERIC + 1
160 #define KEYWORD_PARSE KEYWORD_OPTIONS + 1
161 #define KEYWORD_PROCEDURE KEYWORD_PARSE + 1
162 #define KEYWORD_PULL KEYWORD_PROCEDURE + 1
163 #define KEYWORD_PUSH KEYWORD_PULL + 1
164 #define KEYWORD_QUEUE KEYWORD_PUSH + 1
165 #define KEYWORD_REPLY KEYWORD_QUEUE + 1
166 #define KEYWORD_RETURN KEYWORD_REPLY + 1
167 #define KEYWORD_SAY KEYWORD_RETURN + 1
168 #define KEYWORD_SELECT KEYWORD_SAY + 1
169 #define KEYWORD_SIGNAL KEYWORD_SELECT + 1
170 #define KEYWORD_TRACE KEYWORD_SIGNAL + 1
171 #define KEYWORD_VAR KEYWORD_TRACE + 1
172 #define KEYWORD_GUARD KEYWORD_VAR + 1
173 #define KEYWORD_USE KEYWORD_GUARD + 1
174 #define KEYWORD_INITPROC KEYWORD_USE + 1
175 #define KEYWORD_EXPOSE KEYWORD_INITPROC + 1
176 #define KEYWORD_RAISE KEYWORD_EXPOSE + 1
177 #define KEYWORD_ELSE KEYWORD_RAISE + 1
178 #define KEYWORD_THEN KEYWORD_ELSE + 1
179 #define KEYWORD_END KEYWORD_THEN + 1
180 #define KEYWORD_OTHERWISE KEYWORD_END + 1
181 #define KEYWORD_IFTHEN KEYWORD_OTHERWISE + 1
182 #define KEYWORD_WHENTHEN KEYWORD_IFTHEN + 1
183 #define KEYWORD_WHEN KEYWORD_WHENTHEN + 1
184 #define KEYWORD_ASSIGNMENT KEYWORD_WHEN + 1
185 #define KEYWORD_COMMAND KEYWORD_ASSIGNMENT + 1
186 #define KEYWORD_MESSAGE KEYWORD_COMMAND + 1
187 #define KEYWORD_LABEL KEYWORD_MESSAGE + 1
188 #define KEYWORD_ENDIF KEYWORD_LABEL + 1
189 #define KEYWORD_BLOCK KEYWORD_ENDIF + 1
190 #define KEYWORD_FIRST KEYWORD_BLOCK + 1
191 #define KEYWORD_LAST KEYWORD_FIRST + 1
192 #define KEYWORD_ENDELSE KEYWORD_LAST + 1
193 #define KEYWORD_ENDTHEN KEYWORD_ENDELSE + 1
194 #define KEYWORD_ENDWHEN KEYWORD_ENDTHEN + 1
195 #define KEYWORD_REQUIRES KEYWORD_ENDWHEN + 1
196 #define KEYWORD_CLASS KEYWORD_REQUIRES + 1
197 #define KEYWORD_INSTRUCTION KEYWORD_CLASS + 1
198 #define KEYWORD_FORWARD KEYWORD_INSTRUCTION + 1
199 #define KEYWORD_LOOP KEYWORD_FORWARD + 1
200 #define KEYWORD_LIBRARY KEYWORD_LOOP + 1
201 #define KEYWORD_UPPER KEYWORD_LIBRARY + 1
202 
203 /* token extended types - instruction option keywords */
204 #define IS_SUBKEY 2200 // refined token subclass
205 #define SUBKEY_ARG 1
206 #define SUBKEY_BY SUBKEY_ARG + 1
207 #define SUBKEY_DIGITS SUBKEY_BY + 1
208 #define SUBKEY_END SUBKEY_DIGITS + 1
209 #define SUBKEY_ELSE SUBKEY_END + 1
210 #define SUBKEY_ENGINEERING SUBKEY_ELSE + 1
211 #define SUBKEY_EXPOSE SUBKEY_ENGINEERING + 1
212 #define SUBKEY_FOR SUBKEY_EXPOSE + 1
213 #define SUBKEY_FOREVER SUBKEY_FOR + 1
214 #define SUBKEY_FORM SUBKEY_FOREVER + 1
215 #define SUBKEY_FUZZ SUBKEY_FORM + 1
216 #define SUBKEY_LINEIN SUBKEY_FUZZ + 1
217 #define SUBKEY_LOWER SUBKEY_LINEIN + 1
218 #define SUBKEY_CASELESS SUBKEY_LOWER + 1
219 #define SUBKEY_NAME SUBKEY_CASELESS + 1
220 #define SUBKEY_NOVALUE SUBKEY_NAME + 1
221 #define SUBKEY_OFF SUBKEY_NOVALUE + 1
222 #define SUBKEY_ON SUBKEY_OFF + 1
223 #define SUBKEY_OTHERWISE SUBKEY_ON + 1
224 #define SUBKEY_OVER SUBKEY_OTHERWISE + 1
225 #define SUBKEY_PULL SUBKEY_OVER + 1
226 #define SUBKEY_SCIENTIFIC SUBKEY_PULL + 1
227 #define SUBKEY_SOURCE SUBKEY_SCIENTIFIC + 1
228 #define SUBKEY_THEN SUBKEY_SOURCE + 1
229 #define SUBKEY_TO SUBKEY_THEN + 1
230 #define SUBKEY_UNTIL SUBKEY_TO + 1
231 #define SUBKEY_UPPER SUBKEY_UNTIL + 1
232 #define SUBKEY_VALUE SUBKEY_UPPER + 1
233 #define SUBKEY_VAR SUBKEY_VALUE + 1
234 #define SUBKEY_VERSION SUBKEY_VAR + 1
235 #define SUBKEY_WHEN SUBKEY_VERSION + 1
236 #define SUBKEY_WHILE SUBKEY_WHEN + 1
237 #define SUBKEY_WITH SUBKEY_WHILE + 1
238 #define SUBKEY_DESCRIPTION SUBKEY_WITH + 1
239 #define SUBKEY_ADDITIONAL SUBKEY_DESCRIPTION + 1
240 #define SUBKEY_RESULT SUBKEY_ADDITIONAL + 1
241 #define SUBKEY_ARRAY SUBKEY_RESULT + 1
242 #define SUBKEY_RETURN SUBKEY_ARRAY + 1
243 #define SUBKEY_EXIT SUBKEY_RETURN + 1
244 #define SUBKEY_CONTINUE SUBKEY_EXIT + 1
245 #define SUBKEY_CLASS SUBKEY_CONTINUE + 1
246 #define SUBKEY_MESSAGE SUBKEY_CLASS + 1
247 #define SUBKEY_ARGUMENTS SUBKEY_MESSAGE + 1
248 #define SUBKEY_LABEL SUBKEY_ARGUMENTS + 1
249 #define SUBKEY_STRICT SUBKEY_LABEL + 1
250 #define SUBKEY_TRUE SUBKEY_STRICT + 1
251 #define SUBKEY_FALSE SUBKEY_TRUE + 1
252 #define SUBKEY_NAMEDARGUMENTS SUBKEY_TRUE + 1
253 #define SUBKEY_NAMED SUBKEY_NAMEDARGUMENTS + 1
254 #define SUBKEY_AUTO SUBKEY_NAMED + 1
255 #define SUBKEY_PROPAGATE SUBKEY_AUTO + 1
256 
257 /* token extended types - end of clause */
258 #define CLAUSEEND_EOF 2301
259 #define CLAUSEEND_SEMICOLON 2302
260 #define CLAUSEEND_EOL 2303
261 #define CLAUSEEND_NULL 2304
262 
263 /* directive types */
264 #define IS_DIRECTIVE 2400 // refined token subclass
265 #define DIRECTIVE_REQUIRES 2401
266 #define DIRECTIVE_CLASS 2402
267 #define DIRECTIVE_METHOD 2403
268 #define DIRECTIVE_ROUTINE 2404
269 #define DIRECTIVE_ATTRIBUTE 2405
270 #define DIRECTIVE_CONSTANT 2406
271 #define DIRECTIVE_OPTIONS 2407
272 #define DIRECTIVE_EXTENSION 2408
273 
274 /* directive sub-keywords */
275 #define IS_SUBDIRECTIVE 2500 // refined token subclass
276 #define SUBDIRECTIVE_PUBLIC 2501
277 #define SUBDIRECTIVE_METACLASS 2502
278 #define SUBDIRECTIVE_INHERIT 2503
279 #define SUBDIRECTIVE_PRIVATE 2504
280 #define SUBDIRECTIVE_GUARDED 2505
281 #define SUBDIRECTIVE_CLASS 2506
282 #define SUBDIRECTIVE_EXTERNAL 2507
283 #define SUBDIRECTIVE_SUBCLASS 2508
284 #define SUBDIRECTIVE_UNGUARDED 2509
285 #define SUBDIRECTIVE_MIXINCLASS 2510
286 #define SUBDIRECTIVE_ATTRIBUTE 2511
287 #define SUBDIRECTIVE_PROTECTED 2512
288 #define SUBDIRECTIVE_ABSTRACT 2513
289 #define SUBDIRECTIVE_UNPROTECTED 2514
290 #define SUBDIRECTIVE_GET 2515
291 #define SUBDIRECTIVE_SET 2516
292 #define SUBDIRECTIVE_LIBRARY 2517
293 #define SUBDIRECTIVE_DIGITS 2518
294 #define SUBDIRECTIVE_FORM 2519
295 #define SUBDIRECTIVE_FUZZ 2520
296 #define SUBDIRECTIVE_TRACE 2521
297 #define SUBDIRECTIVE_COMMANDS 2522
298 #define SUBDIRECTIVE_NOCOMMANDS 2523
299 #define SUBDIRECTIVE_MACROSPACE 2524
300 #define SUBDIRECTIVE_NOMACROSPACE 2525
301 #define SUBDIRECTIVE_PACKAGE 2526
302 
303 /* condition keywords */
304 #define IS_CONDITION 2600 // refined token subclass
305 #define CONDITION_ANY 2601
306 #define CONDITION_ERROR 2602
307 #define CONDITION_FAILURE 2603
308 #define CONDITION_HALT 2604
309 #define CONDITION_NOMETHOD 2605
310 #define CONDITION_NOSTRING 2606
311 #define CONDITION_NOTREADY 2607
312 #define CONDITION_NOVALUE 2608
313 #define CONDITION_PROPAGATE 2609
314 #define CONDITION_SYNTAX 2610
315 #define CONDITION_USER 2611
316 #define CONDITION_LOSTDIGITS 2612
317 
318 /* builtin function codes */
319 #define NO_BUILTIN 0 /* builtin function not found */
320 
321 #define IS_BUILTIN 2700 // refined token subclass
322 
323 #define BUILTIN_ABBREV 1
324 #define BUILTIN_ABS BUILTIN_ABBREV + 1
325 #define BUILTIN_ADDRESS BUILTIN_ABS + 1
326 #define BUILTIN_ARG BUILTIN_ADDRESS + 1
327 #define BUILTIN_B2X BUILTIN_ARG + 1
328 #define BUILTIN_BITAND BUILTIN_B2X + 1
329 #define BUILTIN_BITOR BUILTIN_BITAND + 1
330 #define BUILTIN_BITXOR BUILTIN_BITOR + 1
331 #define BUILTIN_C2D BUILTIN_BITXOR + 1
332 #define BUILTIN_C2X BUILTIN_C2D + 1
333 #define BUILTIN_CENTER BUILTIN_C2X + 1
334 #define BUILTIN_CENTRE BUILTIN_CENTER + 1
335 #define BUILTIN_CHANGESTR BUILTIN_CENTRE + 1
336 #define BUILTIN_CHARIN BUILTIN_CHANGESTR + 1
337 #define BUILTIN_CHAROUT BUILTIN_CHARIN + 1
338 #define BUILTIN_CHARS BUILTIN_CHAROUT + 1
339 #define BUILTIN_COMPARE BUILTIN_CHARS + 1
340 #define BUILTIN_CONDITION BUILTIN_COMPARE + 1
341 #define BUILTIN_COPIES BUILTIN_CONDITION + 1
342 #define BUILTIN_COUNTSTR BUILTIN_COPIES + 1
343 #define BUILTIN_D2C BUILTIN_COUNTSTR + 1
344 #define BUILTIN_D2X BUILTIN_D2C + 1
345 #define BUILTIN_DATATYPE BUILTIN_D2X + 1
346 #define BUILTIN_DATE BUILTIN_DATATYPE + 1
347 #define BUILTIN_DELSTR BUILTIN_DATE + 1
348 #define BUILTIN_DELWORD BUILTIN_DELSTR + 1
349 #define BUILTIN_DIGITS BUILTIN_DELWORD + 1
350 #define BUILTIN_ERRORTEXT BUILTIN_DIGITS + 1
351 #define BUILTIN_FORM BUILTIN_ERRORTEXT + 1
352 #define BUILTIN_FORMAT BUILTIN_FORM + 1
353 #define BUILTIN_FUZZ BUILTIN_FORMAT + 1
354 #define BUILTIN_INSERT BUILTIN_FUZZ + 1
355 #define BUILTIN_LASTPOS BUILTIN_INSERT + 1
356 #define BUILTIN_LEFT BUILTIN_LASTPOS + 1
357 #define BUILTIN_LENGTH BUILTIN_LEFT + 1
358 #define BUILTIN_LINEIN BUILTIN_LENGTH + 1
359 #define BUILTIN_LINEOUT BUILTIN_LINEIN + 1
360 #define BUILTIN_LINES BUILTIN_LINEOUT + 1
361 #define BUILTIN_MAX BUILTIN_LINES + 1
362 #define BUILTIN_MIN BUILTIN_MAX + 1
363 #define BUILTIN_OVERLAY BUILTIN_MIN + 1
364 #define BUILTIN_POS BUILTIN_OVERLAY + 1
365 #define BUILTIN_QUEUED BUILTIN_POS + 1
366 #define BUILTIN_RANDOM BUILTIN_QUEUED + 1
367 #define BUILTIN_REVERSE BUILTIN_RANDOM + 1
368 #define BUILTIN_RIGHT BUILTIN_REVERSE + 1
369 #define BUILTIN_SIGN BUILTIN_RIGHT + 1
370 #define BUILTIN_SOURCELINE BUILTIN_SIGN + 1
371 #define BUILTIN_SPACE BUILTIN_SOURCELINE + 1
372 #define BUILTIN_STREAM BUILTIN_SPACE + 1
373 #define BUILTIN_STRIP BUILTIN_STREAM + 1
374 #define BUILTIN_SUBSTR BUILTIN_STRIP + 1
375 #define BUILTIN_SUBWORD BUILTIN_SUBSTR + 1
376 #define BUILTIN_SYMBOL BUILTIN_SUBWORD + 1
377 #define BUILTIN_TIME BUILTIN_SYMBOL + 1
378 #define BUILTIN_TRACE BUILTIN_TIME + 1
379 #define BUILTIN_TRANSLATE BUILTIN_TRACE + 1
380 #define BUILTIN_TRUNC BUILTIN_TRANSLATE + 1
381 #define BUILTIN_VALUE BUILTIN_TRUNC + 1
382 #define BUILTIN_VAR BUILTIN_VALUE + 1
383 #define BUILTIN_VERIFY BUILTIN_VAR + 1
384 #define BUILTIN_WORD BUILTIN_VERIFY + 1
385 #define BUILTIN_WORDINDEX BUILTIN_WORD + 1
386 #define BUILTIN_WORDLENGTH BUILTIN_WORDINDEX + 1
387 #define BUILTIN_WORDPOS BUILTIN_WORDLENGTH + 1
388 #define BUILTIN_WORDS BUILTIN_WORDPOS + 1
389 #define BUILTIN_X2B BUILTIN_WORDS + 1
390 #define BUILTIN_X2C BUILTIN_X2B + 1
391 #define BUILTIN_X2D BUILTIN_X2C + 1
392 #define BUILTIN_XRANGE BUILTIN_X2D + 1
393 // not sorted in alphabetically for security reasons...
394 // WARNING: this makes tokenized scripts incomptabile with
395 // previous tokenized scripts (new tokenized scripts
396 // cannot be run on older versions if USERID is used)
397 // the magic number in the tokenized format is increased
398 // for that reason
399 #define BUILTIN_USERID BUILTIN_XRANGE + 1
400 #define BUILTIN_LOWER BUILTIN_USERID + 1
401 #define BUILTIN_UPPER BUILTIN_LOWER + 1
402 #define BUILTIN_RXFUNCADD BUILTIN_UPPER + 1
403 #define BUILTIN_RXFUNCDROP BUILTIN_RXFUNCADD + 1
404 #define BUILTIN_RXFUNCQUERY BUILTIN_RXFUNCDROP + 1
405 #define BUILTIN_ENDLOCAL BUILTIN_RXFUNCQUERY + 1
406 #define BUILTIN_SETLOCAL BUILTIN_ENDLOCAL + 1
407 #define BUILTIN_QUEUEEXIT BUILTIN_SETLOCAL + 1
408 #define BUILTIN_QUALIFY BUILTIN_QUEUEEXIT + 1
409 
410 
411 
413  public:
414  static const char *codeText(int code);
415  static const char *keywordText(int code);
416 
417  void *operator new(size_t);
418  inline void *operator new(size_t size, void *ptr) {return ptr;};
419  inline void operator delete(void *) { ; }
420  inline void operator delete(void *, void *) { ; }
421 
422  RexxToken(int, int, RexxString *, SourceLocation &);
423  inline RexxToken(RESTORETYPE restoreType) { ; };
424  void live(size_t);
425  void liveGeneral(int reason);
426  void flatten(RexxEnvelope *);
427  inline void setStart(size_t l, size_t o) { tokenLocation.setStart(l, o); }
428  inline void setEnd(size_t l, size_t o) { tokenLocation.setEnd(l, o); }
429 
430  inline bool isType(TokenClass t) { return classId == t; }
431  inline bool isType(TokenClass t1, TokenClass t2) { return classId == t1 || classId == t2; }
432  inline bool isType(TokenClass t1, TokenClass t2, TokenClass t3) { return classId == t1 || classId == t2 || classId == t3; }
433 
434  inline bool isVariable() { return (this->subclass == SYMBOL_VARIABLE || this->subclass == SYMBOL_STEM || this->subclass == SYMBOL_COMPOUND); };
435  inline bool isLiteral() { return (this->classId == TOKEN_LITERAL); };
436  inline bool isSourceLiteral() { return (this->classId == TOKEN_SOURCE_LITERAL); };
437  inline bool isSymbolOrLiteral() { return (this->classId == TOKEN_LITERAL) || (this->classId == TOKEN_SYMBOL); };
438  inline bool isConstant() { return (this->classId == TOKEN_SYMBOL && this->subclass != SYMBOL_VARIABLE && this->subclass != SYMBOL_STEM && this->subclass != SYMBOL_COMPOUND); };
439  inline bool isSymbol() { return (this->classId == TOKEN_SYMBOL); };
440  inline bool isOperator() { return (this->classId == TOKEN_OPERATOR); }
441  inline bool isEndOfClause() { return this->classId == TOKEN_EOC; }
442  inline void setNumeric(int v) { this->numeric = v; };
443  inline const SourceLocation &getLocation() { return tokenLocation; }
444  inline void setLocation(SourceLocation &l) { tokenLocation = l; }
445  void checkAssignment(RexxSource *source, RexxString *newValue);
446 
447  SourceLocation tokenLocation; /* token source location */
448  RexxString *value; /* token string value */
449  int classId; /* class of token */
450  int subclass; /* specialized type of token */
451  int numeric; /* even further specialization */
452  int precedence; /* let override default operator precedence when not zero */
453 };
454 
455 
456 inline RexxArray *new_arrayOfTokens(size_t n) { return memoryObject.newObjects(sizeof(RexxToken), n, T_Token); }
457 inline RexxToken *new_token(int c, int s, RexxString *v, SourceLocation &l) { return new RexxToken (c, s, v, l); }
458 
459 #endif
@ T_Token
RESTORETYPE
Definition: ObjectClass.hpp:82
RexxMemory memoryObject
Definition: RexxMemory.cpp:86
#define TOKEN_LITERAL
Definition: Token.hpp:79
int TokenClass
Definition: Token.hpp:75
#define TOKEN_OPERATOR
Definition: Token.hpp:80
RexxToken * new_token(int c, int s, RexxString *v, SourceLocation &l)
Definition: Token.hpp:457
#define SYMBOL_COMPOUND
Definition: Token.hpp:101
#define SYMBOL_STEM
Definition: Token.hpp:102
#define SYMBOL_VARIABLE
Definition: Token.hpp:99
#define TOKEN_EOC
Definition: Token.hpp:81
RexxArray * new_arrayOfTokens(size_t n)
Definition: Token.hpp:456
#define TOKEN_SYMBOL
Definition: Token.hpp:78
#define TOKEN_SOURCE_LITERAL
Definition: Token.hpp:95
RexxArray * newObjects(size_t size, size_t count, size_t objectType)
int numeric
Definition: Token.hpp:451
RexxString * value
Definition: Token.hpp:448
void setEnd(size_t l, size_t o)
Definition: Token.hpp:428
SourceLocation tokenLocation
Definition: Token.hpp:447
void flatten(RexxEnvelope *)
Definition: Token.cpp:84
static const char * keywordText(int code)
Definition: Token.cpp:236
RexxToken(int, int, RexxString *, SourceLocation &)
Definition: Token.cpp:51
void setNumeric(int v)
Definition: Token.hpp:442
static const char * codeText(int code)
Definition: Token.cpp:128
const SourceLocation & getLocation()
Definition: Token.hpp:443
bool isType(TokenClass t1, TokenClass t2)
Definition: Token.hpp:431
bool isType(TokenClass t1, TokenClass t2, TokenClass t3)
Definition: Token.hpp:432
bool isSymbol()
Definition: Token.hpp:439
bool isSymbolOrLiteral()
Definition: Token.hpp:437
void checkAssignment(RexxSource *source, RexxString *newValue)
Definition: Token.cpp:103
bool isType(TokenClass t)
Definition: Token.hpp:430
void liveGeneral(int reason)
Definition: Token.cpp:76
bool isVariable()
Definition: Token.hpp:434
int precedence
Definition: Token.hpp:452
void setStart(size_t l, size_t o)
Definition: Token.hpp:427
RexxToken(RESTORETYPE restoreType)
Definition: Token.hpp:423
bool isOperator()
Definition: Token.hpp:440
bool isSourceLiteral()
Definition: Token.hpp:436
bool isLiteral()
Definition: Token.hpp:435
bool isConstant()
Definition: Token.hpp:438
bool isEndOfClause()
Definition: Token.hpp:441
int classId
Definition: Token.hpp:449
int subclass
Definition: Token.hpp:450
void setLocation(SourceLocation &l)
Definition: Token.hpp:444
void live(size_t)
Definition: Token.cpp:68
void setEnd(SourceLocation &l)
void setStart(SourceLocation &l)