diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/YEngine/MMRScriptTokenize.cs | 2972 |
1 files changed, 2972 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptTokenize.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptTokenize.cs new file mode 100644 index 0000000..1bcb5b6 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptTokenize.cs | |||
@@ -0,0 +1,2972 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | /** | ||
29 | * @brief Parse raw source file string into token list. | ||
30 | * | ||
31 | * Usage: | ||
32 | * | ||
33 | * emsg = some function to output error messages to | ||
34 | * source = string containing entire source file | ||
35 | * | ||
36 | * TokenBegin tokenBegin = TokenBegin.Construct (emsg, source); | ||
37 | * | ||
38 | * tokenBegin = null: tokenizing error | ||
39 | * else: first (dummy) token in file | ||
40 | * the rest are chained by nextToken,prevToken | ||
41 | * final token is always a (dummy) TokenEnd | ||
42 | */ | ||
43 | |||
44 | using System; | ||
45 | using System.Collections.Generic; | ||
46 | using System.IO; | ||
47 | using System.Net; | ||
48 | using System.Reflection; | ||
49 | using System.Reflection.Emit; | ||
50 | using System.Text; | ||
51 | |||
52 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | ||
53 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
54 | using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
55 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | ||
56 | using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
57 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
58 | using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
59 | |||
60 | namespace OpenSim.Region.ScriptEngine.Yengine | ||
61 | { | ||
62 | |||
63 | public delegate void TokenErrorMessage(Token token, string message); | ||
64 | |||
65 | /** | ||
66 | * @brief base class for all tokens | ||
67 | */ | ||
68 | public class Token | ||
69 | { | ||
70 | public static readonly int MAX_NAME_LEN = 255; | ||
71 | public static readonly int MAX_STRING_LEN = 4096; | ||
72 | |||
73 | public Token nextToken; | ||
74 | public Token prevToken; | ||
75 | public bool nr2l; | ||
76 | |||
77 | // used for error message printing | ||
78 | public TokenErrorMessage emsg; | ||
79 | public string file = ""; | ||
80 | public int line; | ||
81 | public int posn; | ||
82 | public Token copiedFrom; | ||
83 | |||
84 | /** | ||
85 | * @brief construct a token coming directly from a source file | ||
86 | * @param emsg = object that error messages get sent to | ||
87 | * @param file = source file name (or "" if none) | ||
88 | * @param line = source file line number | ||
89 | * @param posn = token's position within that source line | ||
90 | */ | ||
91 | public Token(TokenErrorMessage emsg, string file, int line, int posn) | ||
92 | { | ||
93 | this.emsg = emsg; | ||
94 | this.file = file; | ||
95 | this.line = line; | ||
96 | this.posn = posn; | ||
97 | } | ||
98 | |||
99 | /** | ||
100 | * @brief construct a token with same error message parameters | ||
101 | * @param original = original token to create from | ||
102 | */ | ||
103 | public Token(Token original) | ||
104 | { | ||
105 | if(original != null) | ||
106 | { | ||
107 | this.emsg = original.emsg; | ||
108 | this.file = original.file; | ||
109 | this.line = original.line; | ||
110 | this.posn = original.posn; | ||
111 | this.nr2l = original.nr2l; | ||
112 | } | ||
113 | } | ||
114 | |||
115 | /** | ||
116 | * @brief output an error message associated with this token | ||
117 | * sends the message to the token's error object | ||
118 | * @param message = error message string | ||
119 | */ | ||
120 | public void ErrorMsg(string message) | ||
121 | { | ||
122 | if(emsg != null) | ||
123 | { | ||
124 | emsg(this, message); | ||
125 | } | ||
126 | } | ||
127 | |||
128 | /* | ||
129 | * Generate a unique string (for use in CIL label names, etc) | ||
130 | */ | ||
131 | public string Unique | ||
132 | { | ||
133 | get | ||
134 | { | ||
135 | return file + "_" + line + "_" + posn; | ||
136 | } | ||
137 | } | ||
138 | |||
139 | /* | ||
140 | * Generate source location string (for use in error messages) | ||
141 | */ | ||
142 | public string SrcLoc | ||
143 | { | ||
144 | get | ||
145 | { | ||
146 | string loc = file + "(" + line + "," + posn + ")"; | ||
147 | if(copiedFrom == null) | ||
148 | return loc; | ||
149 | string fromLoc = copiedFrom.SrcLoc; | ||
150 | if(fromLoc.StartsWith(loc)) | ||
151 | return fromLoc; | ||
152 | return loc + ":" + fromLoc; | ||
153 | } | ||
154 | } | ||
155 | |||
156 | /* | ||
157 | * Used in generic instantiation to copy token. | ||
158 | * Only valid for parsing tokens, not reduction tokens | ||
159 | * because it is a shallow copy. | ||
160 | */ | ||
161 | public Token CopyToken(Token src) | ||
162 | { | ||
163 | Token t = (Token)this.MemberwiseClone(); | ||
164 | t.file = src.file; | ||
165 | t.line = src.line; | ||
166 | t.posn = src.posn; | ||
167 | t.copiedFrom = this; | ||
168 | return t; | ||
169 | } | ||
170 | |||
171 | /* | ||
172 | * Generate debugging string - should look like source code. | ||
173 | */ | ||
174 | public virtual void DebString(StringBuilder sb) | ||
175 | { | ||
176 | sb.Append(this.ToString()); | ||
177 | } | ||
178 | } | ||
179 | |||
180 | |||
181 | /** | ||
182 | * @brief token that begins a source file | ||
183 | * Along with TokenEnd, it keeps insertion/removal of intermediate tokens | ||
184 | * simple as the intermediate tokens always have non-null nextToken,prevToken. | ||
185 | */ | ||
186 | public class TokenBegin: Token | ||
187 | { | ||
188 | private class Options | ||
189 | { | ||
190 | public bool arrays; // has seen 'XMROption arrays;' | ||
191 | public bool advFlowCtl; // has seen 'XMROption advFlowCtl;' | ||
192 | public bool tryCatch; // has seen 'XMROption tryCatch;' | ||
193 | public bool objects; // has seen 'XMROption objects;' | ||
194 | public bool chars; // has seen 'XMROption chars;' | ||
195 | public bool noRightToLeft; // has seen 'XMROption noRightToLeft;' | ||
196 | public bool dollarsigns; // has seen 'XMROption dollarsigns;' | ||
197 | } | ||
198 | |||
199 | private bool youveAnError; // there was some error tokenizing | ||
200 | private int bolIdx; // index in 'source' at begining of current line | ||
201 | private int lineNo; // current line in source file, starting at 0 | ||
202 | private string filNam; // current source file name | ||
203 | private string source; // the whole script source code | ||
204 | private Token lastToken; // last token created so far | ||
205 | private string cameFrom; // where the source came from | ||
206 | private TextWriter saveSource; // save copy of source here (or null) | ||
207 | private Options options = new Options(); | ||
208 | |||
209 | /** | ||
210 | * @brief convert a source file in the form of a string | ||
211 | * to a list of raw tokens | ||
212 | * @param cameFrom = where the source came from | ||
213 | * @param emsg = where to output messages to | ||
214 | * @param source = whole source file contents | ||
215 | * @returns null: conversion error, message already output | ||
216 | * else: list of tokens, starting with TokenBegin, ending with TokenEnd. | ||
217 | */ | ||
218 | public static TokenBegin Construct(string cameFrom, TextWriter saveSource, TokenErrorMessage emsg, string source, out string sourceHash) | ||
219 | { | ||
220 | sourceHash = null; | ||
221 | |||
222 | /* | ||
223 | * Now do the tokenization. | ||
224 | */ | ||
225 | TokenBegin tokenBegin = new TokenBegin(emsg, "", 0, 0); | ||
226 | tokenBegin.cameFrom = cameFrom; | ||
227 | tokenBegin.saveSource = saveSource; | ||
228 | tokenBegin.lastToken = tokenBegin; | ||
229 | tokenBegin.source = source; | ||
230 | tokenBegin.filNam = cameFrom; | ||
231 | if(saveSource != null) | ||
232 | saveSource.WriteLine(source); | ||
233 | tokenBegin.Tokenize(); | ||
234 | if(tokenBegin.youveAnError) | ||
235 | return null; | ||
236 | tokenBegin.AppendToken(new TokenEnd(emsg, tokenBegin.filNam, ++tokenBegin.lineNo, 0)); | ||
237 | |||
238 | /* | ||
239 | * Return source hash so caller can know if source changes. | ||
240 | */ | ||
241 | System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create(); | ||
242 | byte[] hashBytes = md5.ComputeHash(new TokenStream(tokenBegin)); | ||
243 | int hashBytesLen = hashBytes.Length; | ||
244 | StringBuilder sb = new StringBuilder(hashBytesLen * 2); | ||
245 | for(int i = 0; i < hashBytesLen; i++) | ||
246 | { | ||
247 | sb.Append(hashBytes[i].ToString("X2")); | ||
248 | } | ||
249 | sourceHash = sb.ToString(); | ||
250 | if(saveSource != null) | ||
251 | { | ||
252 | saveSource.WriteLine(""); | ||
253 | saveSource.WriteLine("********************************************************************************"); | ||
254 | saveSource.WriteLine("**** source hash: " + sourceHash); | ||
255 | saveSource.WriteLine("********************************************************************************"); | ||
256 | } | ||
257 | |||
258 | return tokenBegin; | ||
259 | } | ||
260 | |||
261 | private TokenBegin(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { } | ||
262 | |||
263 | /* | ||
264 | * Stream consisting of all the tokens. | ||
265 | * Null delimeters between the tokens. | ||
266 | * Used for creating the source hash. | ||
267 | */ | ||
268 | private class TokenStream: Stream | ||
269 | { | ||
270 | private Token curTok; | ||
271 | private bool delim; | ||
272 | private byte[] curBuf; | ||
273 | private int curOfs; | ||
274 | private int curLen; | ||
275 | |||
276 | public TokenStream(Token t) | ||
277 | { | ||
278 | curTok = t; | ||
279 | } | ||
280 | |||
281 | public override bool CanRead | ||
282 | { | ||
283 | get | ||
284 | { | ||
285 | return true; | ||
286 | } | ||
287 | } | ||
288 | public override bool CanSeek | ||
289 | { | ||
290 | get | ||
291 | { | ||
292 | return false; | ||
293 | } | ||
294 | } | ||
295 | public override bool CanWrite | ||
296 | { | ||
297 | get | ||
298 | { | ||
299 | return false; | ||
300 | } | ||
301 | } | ||
302 | public override long Length | ||
303 | { | ||
304 | get | ||
305 | { | ||
306 | return 0; | ||
307 | } | ||
308 | } | ||
309 | public override long Position | ||
310 | { | ||
311 | get | ||
312 | { | ||
313 | return 0; | ||
314 | } | ||
315 | set | ||
316 | { | ||
317 | } | ||
318 | } | ||
319 | |||
320 | public override void Write(byte[] buffer, int offset, int count) | ||
321 | { | ||
322 | } | ||
323 | public override void Flush() | ||
324 | { | ||
325 | } | ||
326 | public override long Seek(long offset, SeekOrigin origin) | ||
327 | { | ||
328 | return 0; | ||
329 | } | ||
330 | public override void SetLength(long value) | ||
331 | { | ||
332 | } | ||
333 | |||
334 | public override int Read(byte[] buffer, int offset, int count) | ||
335 | { | ||
336 | int len, total; | ||
337 | for(total = 0; total < count; total += len) | ||
338 | { | ||
339 | while((len = curLen - curOfs) <= 0) | ||
340 | { | ||
341 | if(curTok is TokenEnd) | ||
342 | goto done; | ||
343 | curTok = curTok.nextToken; | ||
344 | if(curTok is TokenEnd) | ||
345 | goto done; | ||
346 | curBuf = System.Text.Encoding.UTF8.GetBytes(curTok.ToString()); | ||
347 | curOfs = 0; | ||
348 | curLen = curBuf.Length; | ||
349 | delim = true; | ||
350 | } | ||
351 | if(delim) | ||
352 | { | ||
353 | buffer[offset + total] = 0; | ||
354 | delim = false; | ||
355 | len = 1; | ||
356 | } | ||
357 | else | ||
358 | { | ||
359 | if(len > count - total) | ||
360 | len = count - total; | ||
361 | Array.Copy(curBuf, curOfs, buffer, offset + total, len); | ||
362 | curOfs += len; | ||
363 | } | ||
364 | } | ||
365 | done: | ||
366 | return total; | ||
367 | } | ||
368 | } | ||
369 | |||
370 | /* | ||
371 | * Produces raw token stream: names, numbers, strings, keywords/delimeters. | ||
372 | * @param this.source = whole source file in one string | ||
373 | * @returns this.nextToken = filled in with tokens | ||
374 | * this.youveAnError = true: some tokenizing error | ||
375 | * false: successful | ||
376 | */ | ||
377 | private void Tokenize() | ||
378 | { | ||
379 | bolIdx = 0; | ||
380 | lineNo = 0; | ||
381 | for(int i = 0; i < source.Length; i++) | ||
382 | { | ||
383 | char c = source[i]; | ||
384 | if(c == '\n') | ||
385 | { | ||
386 | |||
387 | /* | ||
388 | * Increment source line number and set char index of beg of next line. | ||
389 | */ | ||
390 | lineNo++; | ||
391 | bolIdx = i + 1; | ||
392 | |||
393 | /* | ||
394 | * Check for '#' lineno filename newline | ||
395 | * lineno is line number of next line in file | ||
396 | * If found, save values and remove tokens from stream | ||
397 | */ | ||
398 | if((lastToken is TokenStr) && | ||
399 | (lastToken.prevToken is TokenInt) && | ||
400 | (lastToken.prevToken.prevToken is TokenKwHash)) | ||
401 | { | ||
402 | filNam = ((TokenStr)lastToken).val; | ||
403 | lineNo = ((TokenInt)lastToken.prevToken).val; | ||
404 | lastToken = lastToken.prevToken.prevToken.prevToken; | ||
405 | lastToken.nextToken = null; | ||
406 | } | ||
407 | continue; | ||
408 | } | ||
409 | |||
410 | /* | ||
411 | * Skip over whitespace. | ||
412 | */ | ||
413 | if(c <= ' ') | ||
414 | continue; | ||
415 | |||
416 | /* | ||
417 | * Skip over comments. | ||
418 | */ | ||
419 | if((i + 2 <= source.Length) && source.Substring(i, 2).Equals("//")) | ||
420 | { | ||
421 | while((i < source.Length) && (source[i] != '\n')) | ||
422 | i++; | ||
423 | lineNo++; | ||
424 | bolIdx = i + 1; | ||
425 | continue; | ||
426 | } | ||
427 | if((i + 2 <= source.Length) && (source.Substring(i, 2).Equals("/*"))) | ||
428 | { | ||
429 | i += 2; | ||
430 | while((i + 1 < source.Length) && (((c = source[i]) != '*') || (source[i + 1] != '/'))) | ||
431 | { | ||
432 | if(c == '\n') | ||
433 | { | ||
434 | lineNo++; | ||
435 | bolIdx = i + 1; | ||
436 | } | ||
437 | i++; | ||
438 | } | ||
439 | i++; | ||
440 | continue; | ||
441 | } | ||
442 | |||
443 | /* | ||
444 | * Check for numbers. | ||
445 | */ | ||
446 | if((c >= '0') && (c <= '9')) | ||
447 | { | ||
448 | int j = TryParseFloat(i); | ||
449 | if(j == 0) | ||
450 | j = TryParseInt(i); | ||
451 | i = --j; | ||
452 | continue; | ||
453 | } | ||
454 | if((c == '.') && (i + 1 < source.Length) && (source[i + 1] >= '0') && (source[i + 1] <= '9')) | ||
455 | { | ||
456 | int j = TryParseFloat(i); | ||
457 | if(j > 0) | ||
458 | i = --j; | ||
459 | continue; | ||
460 | } | ||
461 | |||
462 | /* | ||
463 | * Check for quoted strings. | ||
464 | */ | ||
465 | if(c == '"') | ||
466 | { | ||
467 | StringBuilder sb = new StringBuilder(); | ||
468 | bool backslash; | ||
469 | int j; | ||
470 | |||
471 | backslash = false; | ||
472 | for(j = i; ++j < source.Length;) | ||
473 | { | ||
474 | c = source[j]; | ||
475 | if(c == '\\' && !backslash) | ||
476 | { | ||
477 | backslash = true; | ||
478 | continue; | ||
479 | } | ||
480 | if(c == '\n') | ||
481 | { | ||
482 | lineNo++; | ||
483 | bolIdx = j + 1; | ||
484 | } | ||
485 | else | ||
486 | { | ||
487 | if(!backslash && (c == '"')) | ||
488 | break; | ||
489 | if(backslash && (c == 'n')) | ||
490 | c = '\n'; | ||
491 | if(backslash && (c == 't')) | ||
492 | { | ||
493 | sb.Append(" "); | ||
494 | c = ' '; | ||
495 | } | ||
496 | } | ||
497 | backslash = false; | ||
498 | sb.Append(c); | ||
499 | } | ||
500 | if(j - i > MAX_STRING_LEN) | ||
501 | { | ||
502 | TokenError(i, "string too long, max " + MAX_STRING_LEN); | ||
503 | } | ||
504 | else | ||
505 | { | ||
506 | AppendToken(new TokenStr(emsg, filNam, lineNo, i - bolIdx, sb.ToString())); | ||
507 | } | ||
508 | i = j; | ||
509 | continue; | ||
510 | } | ||
511 | |||
512 | /* | ||
513 | * Check for quoted characters. | ||
514 | */ | ||
515 | if(c == '\'') | ||
516 | { | ||
517 | char cb = (char)0; | ||
518 | bool backslash, overflow, underflow; | ||
519 | int j; | ||
520 | |||
521 | backslash = false; | ||
522 | overflow = false; | ||
523 | underflow = true; | ||
524 | for(j = i; ++j < source.Length;) | ||
525 | { | ||
526 | c = source[j]; | ||
527 | if(c == '\\' && !backslash) | ||
528 | { | ||
529 | backslash = true; | ||
530 | continue; | ||
531 | } | ||
532 | if(c == '\n') | ||
533 | { | ||
534 | lineNo++; | ||
535 | bolIdx = j + 1; | ||
536 | } | ||
537 | else | ||
538 | { | ||
539 | if(!backslash && (c == '\'')) | ||
540 | break; | ||
541 | if(backslash && (c == 'n')) | ||
542 | c = '\n'; | ||
543 | if(backslash && (c == 't')) | ||
544 | c = '\t'; | ||
545 | } | ||
546 | backslash = false; | ||
547 | overflow = !underflow; | ||
548 | underflow = false; | ||
549 | cb = c; | ||
550 | } | ||
551 | if(underflow || overflow) | ||
552 | { | ||
553 | TokenError(i, "character must be exactly one character"); | ||
554 | } | ||
555 | else | ||
556 | { | ||
557 | AppendToken(new TokenChar(emsg, filNam, lineNo, i - bolIdx, cb)); | ||
558 | } | ||
559 | i = j; | ||
560 | continue; | ||
561 | } | ||
562 | |||
563 | /* | ||
564 | * Check for keywords/names. | ||
565 | */ | ||
566 | if((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c == '_') || (c == '$' && options.dollarsigns)) | ||
567 | { | ||
568 | int j; | ||
569 | |||
570 | for(j = i; ++j < source.Length;) | ||
571 | { | ||
572 | c = source[j]; | ||
573 | if(c >= 'a' && c <= 'z') | ||
574 | continue; | ||
575 | if(c >= 'A' && c <= 'Z') | ||
576 | continue; | ||
577 | if(c >= '0' && c <= '9') | ||
578 | continue; | ||
579 | if(c == '$' && options.dollarsigns) | ||
580 | continue; | ||
581 | if(c != '_') | ||
582 | break; | ||
583 | } | ||
584 | if(j - i > MAX_NAME_LEN) | ||
585 | { | ||
586 | TokenError(i, "name too long, max " + MAX_NAME_LEN); | ||
587 | } | ||
588 | else | ||
589 | { | ||
590 | string name = source.Substring(i, j - i); | ||
591 | if(name == "quaternion") | ||
592 | name = "rotation"; // see lslangtest1.lsl | ||
593 | if(keywords.ContainsKey(name)) | ||
594 | { | ||
595 | Object[] args = new Object[] { emsg, filNam, lineNo, i - bolIdx }; | ||
596 | AppendToken((Token)keywords[name].Invoke(args)); | ||
597 | } | ||
598 | else if(options.arrays && arrayKeywords.ContainsKey(name)) | ||
599 | { | ||
600 | Object[] args = new Object[] { emsg, filNam, lineNo, i - bolIdx }; | ||
601 | AppendToken((Token)arrayKeywords[name].Invoke(args)); | ||
602 | } | ||
603 | else if(options.advFlowCtl && advFlowCtlKeywords.ContainsKey(name)) | ||
604 | { | ||
605 | Object[] args = new Object[] { emsg, filNam, lineNo, i - bolIdx }; | ||
606 | AppendToken((Token)advFlowCtlKeywords[name].Invoke(args)); | ||
607 | } | ||
608 | else if(options.tryCatch && tryCatchKeywords.ContainsKey(name)) | ||
609 | { | ||
610 | Object[] args = new Object[] { emsg, filNam, lineNo, i - bolIdx }; | ||
611 | AppendToken((Token)tryCatchKeywords[name].Invoke(args)); | ||
612 | } | ||
613 | else if(options.objects && objectsKeywords.ContainsKey(name)) | ||
614 | { | ||
615 | Object[] args = new Object[] { emsg, filNam, lineNo, i - bolIdx }; | ||
616 | AppendToken((Token)objectsKeywords[name].Invoke(args)); | ||
617 | } | ||
618 | else if(options.chars && charsKeywords.ContainsKey(name)) | ||
619 | { | ||
620 | Object[] args = new Object[] { emsg, filNam, lineNo, i - bolIdx }; | ||
621 | AppendToken((Token)charsKeywords[name].Invoke(args)); | ||
622 | } | ||
623 | else | ||
624 | { | ||
625 | AppendToken(new TokenName(emsg, filNam, lineNo, i - bolIdx, name)); | ||
626 | } | ||
627 | } | ||
628 | i = --j; | ||
629 | continue; | ||
630 | } | ||
631 | |||
632 | /* | ||
633 | * Check for option enables. | ||
634 | */ | ||
635 | if((c == ';') && (lastToken is TokenName) && | ||
636 | (lastToken.prevToken is TokenName) && | ||
637 | (strcasecmp(((TokenName)lastToken.prevToken).val, "yoption") == 0)) | ||
638 | { | ||
639 | string opt = ((TokenName)lastToken).val; | ||
640 | if(strcasecmp(opt, "allowall") == 0) | ||
641 | { | ||
642 | options.arrays = true; | ||
643 | options.advFlowCtl = true; | ||
644 | options.tryCatch = true; | ||
645 | options.objects = true; | ||
646 | options.chars = true; | ||
647 | // options.noRightToLeft = true; | ||
648 | options.dollarsigns = true; | ||
649 | } | ||
650 | else if(strcasecmp(opt, "arrays") == 0) | ||
651 | options.arrays = true; | ||
652 | else if(strcasecmp(opt, "advflowctl") == 0) | ||
653 | options.advFlowCtl = true; | ||
654 | else if(strcasecmp(opt, "trycatch") == 0) | ||
655 | options.tryCatch = true; | ||
656 | else if(strcasecmp(opt, "objects") == 0) | ||
657 | options.objects = true; | ||
658 | else if(strcasecmp(opt, "chars") == 0) | ||
659 | options.chars = true; | ||
660 | else if(strcasecmp(opt, "norighttoleft") == 0) | ||
661 | options.noRightToLeft = true; | ||
662 | else if(strcasecmp(opt, "dollarsigns") == 0) | ||
663 | options.dollarsigns = true; | ||
664 | else | ||
665 | lastToken.ErrorMsg("unknown YOption"); | ||
666 | |||
667 | lastToken = lastToken.prevToken.prevToken; | ||
668 | lastToken.nextToken = null; | ||
669 | continue; | ||
670 | } | ||
671 | |||
672 | /* | ||
673 | * Lastly, check for delimeters. | ||
674 | */ | ||
675 | { | ||
676 | int j; | ||
677 | int len = 0; | ||
678 | |||
679 | for(j = 0; j < delims.Length; j++) | ||
680 | { | ||
681 | len = delims[j].str.Length; | ||
682 | if((i + len <= source.Length) && (source.Substring(i, len).Equals(delims[j].str))) | ||
683 | break; | ||
684 | } | ||
685 | if(j < delims.Length) | ||
686 | { | ||
687 | Object[] args = { emsg, filNam, lineNo, i - bolIdx }; | ||
688 | Token kwToken = (Token)delims[j].ctorInfo.Invoke(args); | ||
689 | AppendToken(kwToken); | ||
690 | i += --len; | ||
691 | continue; | ||
692 | } | ||
693 | } | ||
694 | |||
695 | /* | ||
696 | * Don't know what it is! | ||
697 | */ | ||
698 | TokenError(i, "unknown character '" + c + "'"); | ||
699 | } | ||
700 | } | ||
701 | |||
702 | private static int strcasecmp(String s, String t) | ||
703 | { | ||
704 | return String.Compare(s, t, StringComparison.OrdinalIgnoreCase); | ||
705 | } | ||
706 | |||
707 | /** | ||
708 | * @brief try to parse a floating-point number from the source | ||
709 | * @param i = starting position within this.source of number | ||
710 | * @returns 0: not a floating point number, try something else | ||
711 | * else: position in this.source of terminating character, ie, past number | ||
712 | * TokenFloat appended to token list | ||
713 | * or error message has been output | ||
714 | */ | ||
715 | private int TryParseFloat(int i) | ||
716 | { | ||
717 | bool decimals, error, negexp, nulexp; | ||
718 | char c; | ||
719 | double f, f10; | ||
720 | int exponent, j, x, y; | ||
721 | ulong m, mantissa; | ||
722 | |||
723 | decimals = false; | ||
724 | error = false; | ||
725 | exponent = 0; | ||
726 | mantissa = 0; | ||
727 | for(j = i; j < source.Length; j++) | ||
728 | { | ||
729 | c = source[j]; | ||
730 | if((c >= '0') && (c <= '9')) | ||
731 | { | ||
732 | m = mantissa * 10 + (ulong)(c - '0'); | ||
733 | if(m / 10 != mantissa) | ||
734 | { | ||
735 | if(!decimals) | ||
736 | exponent++; | ||
737 | } | ||
738 | else | ||
739 | { | ||
740 | mantissa = m; | ||
741 | if(decimals) | ||
742 | exponent--; | ||
743 | } | ||
744 | continue; | ||
745 | } | ||
746 | if(c == '.') | ||
747 | { | ||
748 | if(decimals) | ||
749 | { | ||
750 | TokenError(i, "more than one decimal point"); | ||
751 | return j; | ||
752 | } | ||
753 | decimals = true; | ||
754 | continue; | ||
755 | } | ||
756 | if((c == 'E') || (c == 'e')) | ||
757 | { | ||
758 | if(++j >= source.Length) | ||
759 | { | ||
760 | TokenError(i, "floating exponent off end of source"); | ||
761 | return j; | ||
762 | } | ||
763 | c = source[j]; | ||
764 | negexp = (c == '-'); | ||
765 | if(negexp || (c == '+')) | ||
766 | j++; | ||
767 | y = 0; | ||
768 | nulexp = true; | ||
769 | for(; j < source.Length; j++) | ||
770 | { | ||
771 | c = source[j]; | ||
772 | if((c < '0') || (c > '9')) | ||
773 | break; | ||
774 | x = y * 10 + (c - '0'); | ||
775 | if(x / 10 != y) | ||
776 | { | ||
777 | if(!error) | ||
778 | TokenError(i, "floating exponent overflow"); | ||
779 | error = true; | ||
780 | } | ||
781 | y = x; | ||
782 | nulexp = false; | ||
783 | } | ||
784 | if(nulexp) | ||
785 | { | ||
786 | TokenError(i, "bad or missing floating exponent"); | ||
787 | return j; | ||
788 | } | ||
789 | if(negexp) | ||
790 | { | ||
791 | x = exponent - y; | ||
792 | if(x > exponent) | ||
793 | { | ||
794 | if(!error) | ||
795 | TokenError(i, "floating exponent overflow"); | ||
796 | error = true; | ||
797 | } | ||
798 | } | ||
799 | else | ||
800 | { | ||
801 | x = exponent + y; | ||
802 | if(x < exponent) | ||
803 | { | ||
804 | if(!error) | ||
805 | TokenError(i, "floating exponent overflow"); | ||
806 | error = true; | ||
807 | } | ||
808 | } | ||
809 | exponent = x; | ||
810 | } | ||
811 | break; | ||
812 | } | ||
813 | if(!decimals) | ||
814 | { | ||
815 | return 0; | ||
816 | } | ||
817 | |||
818 | f = mantissa; | ||
819 | if((exponent != 0) && (mantissa != 0) && !error) | ||
820 | { | ||
821 | f10 = 10.0; | ||
822 | if(exponent < 0) | ||
823 | { | ||
824 | exponent = -exponent; | ||
825 | while(exponent > 0) | ||
826 | { | ||
827 | if((exponent & 1) != 0) | ||
828 | { | ||
829 | f /= f10; | ||
830 | } | ||
831 | exponent /= 2; | ||
832 | f10 *= f10; | ||
833 | } | ||
834 | } | ||
835 | else | ||
836 | { | ||
837 | while(exponent > 0) | ||
838 | { | ||
839 | if((exponent & 1) != 0) | ||
840 | { | ||
841 | f *= f10; | ||
842 | } | ||
843 | exponent /= 2; | ||
844 | f10 *= f10; | ||
845 | } | ||
846 | } | ||
847 | } | ||
848 | if(!error) | ||
849 | { | ||
850 | AppendToken(new TokenFloat(emsg, filNam, lineNo, i - bolIdx, f)); | ||
851 | } | ||
852 | return j; | ||
853 | } | ||
854 | |||
855 | /** | ||
856 | * @brief try to parse an integer number from the source | ||
857 | * @param i = starting position within this.source of number | ||
858 | * @returns 0: not an integer number, try something else | ||
859 | * else: position in this.source of terminating character, ie, past number | ||
860 | * TokenInt appended to token list | ||
861 | * or error message has been output | ||
862 | */ | ||
863 | private int TryParseInt(int i) | ||
864 | { | ||
865 | bool error; | ||
866 | char c; | ||
867 | int j; | ||
868 | uint basse, m, mantissa; | ||
869 | |||
870 | basse = 10; | ||
871 | error = false; | ||
872 | mantissa = 0; | ||
873 | for(j = i; j < source.Length; j++) | ||
874 | { | ||
875 | c = source[j]; | ||
876 | if((c >= '0') && (c <= '9')) | ||
877 | { | ||
878 | m = mantissa * basse + (uint)(c - '0'); | ||
879 | if(m / basse != mantissa) | ||
880 | { | ||
881 | if(!error) | ||
882 | TokenError(i, "integer overflow"); | ||
883 | error = true; | ||
884 | } | ||
885 | mantissa = m; | ||
886 | continue; | ||
887 | } | ||
888 | if((basse == 16) && ((c >= 'A') && (c <= 'F'))) | ||
889 | { | ||
890 | m = mantissa * basse + (uint)(c - 'A') + 10U; | ||
891 | if(m / basse != mantissa) | ||
892 | { | ||
893 | if(!error) | ||
894 | TokenError(i, "integer overflow"); | ||
895 | error = true; | ||
896 | } | ||
897 | mantissa = m; | ||
898 | continue; | ||
899 | } | ||
900 | if((basse == 16) && ((c >= 'a') && (c <= 'f'))) | ||
901 | { | ||
902 | m = mantissa * basse + (uint)(c - 'a') + 10U; | ||
903 | if(m / basse != mantissa) | ||
904 | { | ||
905 | if(!error) | ||
906 | TokenError(i, "integer overflow"); | ||
907 | error = true; | ||
908 | } | ||
909 | mantissa = m; | ||
910 | continue; | ||
911 | } | ||
912 | if(((c == 'x') || (c == 'X')) && (mantissa == 0) && (basse == 10)) | ||
913 | { | ||
914 | basse = 16; | ||
915 | continue; | ||
916 | } | ||
917 | break; | ||
918 | } | ||
919 | if(!error) | ||
920 | { | ||
921 | AppendToken(new TokenInt(emsg, filNam, lineNo, i - bolIdx, (int)mantissa)); | ||
922 | } | ||
923 | return j; | ||
924 | } | ||
925 | |||
926 | /** | ||
927 | * @brief append token on to end of list | ||
928 | * @param newToken = token to append | ||
929 | * @returns with token appended onto this.lastToken | ||
930 | */ | ||
931 | private void AppendToken(Token newToken) | ||
932 | { | ||
933 | newToken.nextToken = null; | ||
934 | newToken.prevToken = lastToken; | ||
935 | newToken.nr2l = this.options.noRightToLeft; | ||
936 | lastToken.nextToken = newToken; | ||
937 | lastToken = newToken; | ||
938 | } | ||
939 | |||
940 | /** | ||
941 | * @brief print tokenizing error message | ||
942 | * and remember that we've an error | ||
943 | * @param i = position within source file of the error | ||
944 | * @param message = error message text | ||
945 | * @returns with this.youveAnError set | ||
946 | */ | ||
947 | private void TokenError(int i, string message) | ||
948 | { | ||
949 | Token temp = new Token(this.emsg, this.filNam, this.lineNo, i - this.bolIdx); | ||
950 | temp.ErrorMsg(message); | ||
951 | youveAnError = true; | ||
952 | } | ||
953 | |||
954 | /** | ||
955 | * @brief get a token's constructor | ||
956 | * @param tokenType = token's type | ||
957 | * @returns token's constructor | ||
958 | */ | ||
959 | private static Type[] constrTypes = new Type[] { | ||
960 | typeof (TokenErrorMessage), typeof (string), typeof (int), typeof (int) | ||
961 | }; | ||
962 | |||
963 | private static System.Reflection.ConstructorInfo GetTokenCtor(Type tokenType) | ||
964 | { | ||
965 | return tokenType.GetConstructor(constrTypes); | ||
966 | } | ||
967 | |||
968 | /** | ||
969 | * @brief delimeter table | ||
970 | */ | ||
971 | private class Delim | ||
972 | { | ||
973 | public string str; | ||
974 | public System.Reflection.ConstructorInfo ctorInfo; | ||
975 | public Delim(string str, Type type) | ||
976 | { | ||
977 | this.str = str; | ||
978 | ctorInfo = GetTokenCtor(type); | ||
979 | } | ||
980 | } | ||
981 | |||
982 | private static Delim[] delims = new Delim[] { | ||
983 | new Delim ("...", typeof (TokenKwDotDotDot)), | ||
984 | new Delim ("&&&", typeof (TokenKwAndAndAnd)), | ||
985 | new Delim ("|||", typeof (TokenKwOrOrOr)), | ||
986 | new Delim ("<<=", typeof (TokenKwAsnLSh)), | ||
987 | new Delim (">>=", typeof (TokenKwAsnRSh)), | ||
988 | new Delim ("<=", typeof (TokenKwCmpLE)), | ||
989 | new Delim (">=", typeof (TokenKwCmpGE)), | ||
990 | new Delim ("==", typeof (TokenKwCmpEQ)), | ||
991 | new Delim ("!=", typeof (TokenKwCmpNE)), | ||
992 | new Delim ("++", typeof (TokenKwIncr)), | ||
993 | new Delim ("--", typeof (TokenKwDecr)), | ||
994 | new Delim ("&&", typeof (TokenKwAndAnd)), | ||
995 | new Delim ("||", typeof (TokenKwOrOr)), | ||
996 | new Delim ("+=", typeof (TokenKwAsnAdd)), | ||
997 | new Delim ("&=", typeof (TokenKwAsnAnd)), | ||
998 | new Delim ("-=", typeof (TokenKwAsnSub)), | ||
999 | new Delim ("*=", typeof (TokenKwAsnMul)), | ||
1000 | new Delim ("/=", typeof (TokenKwAsnDiv)), | ||
1001 | new Delim ("%=", typeof (TokenKwAsnMod)), | ||
1002 | new Delim ("|=", typeof (TokenKwAsnOr)), | ||
1003 | new Delim ("^=", typeof (TokenKwAsnXor)), | ||
1004 | new Delim ("<<", typeof (TokenKwLSh)), | ||
1005 | new Delim (">>", typeof (TokenKwRSh)), | ||
1006 | new Delim ("~", typeof (TokenKwTilde)), | ||
1007 | new Delim ("!", typeof (TokenKwExclam)), | ||
1008 | new Delim ("@", typeof (TokenKwAt)), | ||
1009 | new Delim ("%", typeof (TokenKwMod)), | ||
1010 | new Delim ("^", typeof (TokenKwXor)), | ||
1011 | new Delim ("&", typeof (TokenKwAnd)), | ||
1012 | new Delim ("*", typeof (TokenKwMul)), | ||
1013 | new Delim ("(", typeof (TokenKwParOpen)), | ||
1014 | new Delim (")", typeof (TokenKwParClose)), | ||
1015 | new Delim ("-", typeof (TokenKwSub)), | ||
1016 | new Delim ("+", typeof (TokenKwAdd)), | ||
1017 | new Delim ("=", typeof (TokenKwAssign)), | ||
1018 | new Delim ("{", typeof (TokenKwBrcOpen)), | ||
1019 | new Delim ("}", typeof (TokenKwBrcClose)), | ||
1020 | new Delim ("[", typeof (TokenKwBrkOpen)), | ||
1021 | new Delim ("]", typeof (TokenKwBrkClose)), | ||
1022 | new Delim (";", typeof (TokenKwSemi)), | ||
1023 | new Delim (":", typeof (TokenKwColon)), | ||
1024 | new Delim ("<", typeof (TokenKwCmpLT)), | ||
1025 | new Delim (">", typeof (TokenKwCmpGT)), | ||
1026 | new Delim (",", typeof (TokenKwComma)), | ||
1027 | new Delim (".", typeof (TokenKwDot)), | ||
1028 | new Delim ("?", typeof (TokenKwQMark)), | ||
1029 | new Delim ("/", typeof (TokenKwDiv)), | ||
1030 | new Delim ("|", typeof (TokenKwOr)), | ||
1031 | new Delim ("#", typeof (TokenKwHash)) | ||
1032 | }; | ||
1033 | |||
1034 | /** | ||
1035 | * @brief keyword tables | ||
1036 | * The keyword tables translate a keyword string | ||
1037 | * to the corresponding token constructor. | ||
1038 | */ | ||
1039 | private static Dictionary<string, System.Reflection.ConstructorInfo> keywords = BuildKeywords(); | ||
1040 | private static Dictionary<string, System.Reflection.ConstructorInfo> arrayKeywords = BuildArrayKeywords(); | ||
1041 | private static Dictionary<string, System.Reflection.ConstructorInfo> advFlowCtlKeywords = BuildAdvFlowCtlKeywords(); | ||
1042 | private static Dictionary<string, System.Reflection.ConstructorInfo> tryCatchKeywords = BuildTryCatchKeywords(); | ||
1043 | private static Dictionary<string, System.Reflection.ConstructorInfo> objectsKeywords = BuildObjectsKeywords(); | ||
1044 | private static Dictionary<string, System.Reflection.ConstructorInfo> charsKeywords = BuildCharsKeywords(); | ||
1045 | |||
1046 | private static Dictionary<string, System.Reflection.ConstructorInfo> BuildKeywords() | ||
1047 | { | ||
1048 | Dictionary<string, System.Reflection.ConstructorInfo> kws = new Dictionary<string, System.Reflection.ConstructorInfo>(); | ||
1049 | |||
1050 | kws.Add("default", GetTokenCtor(typeof(TokenKwDefault))); | ||
1051 | kws.Add("do", GetTokenCtor(typeof(TokenKwDo))); | ||
1052 | kws.Add("else", GetTokenCtor(typeof(TokenKwElse))); | ||
1053 | kws.Add("float", GetTokenCtor(typeof(TokenTypeFloat))); | ||
1054 | kws.Add("for", GetTokenCtor(typeof(TokenKwFor))); | ||
1055 | kws.Add("if", GetTokenCtor(typeof(TokenKwIf))); | ||
1056 | kws.Add("integer", GetTokenCtor(typeof(TokenTypeInt))); | ||
1057 | kws.Add("list", GetTokenCtor(typeof(TokenTypeList))); | ||
1058 | kws.Add("jump", GetTokenCtor(typeof(TokenKwJump))); | ||
1059 | kws.Add("key", GetTokenCtor(typeof(TokenTypeKey))); | ||
1060 | kws.Add("return", GetTokenCtor(typeof(TokenKwRet))); | ||
1061 | kws.Add("rotation", GetTokenCtor(typeof(TokenTypeRot))); | ||
1062 | kws.Add("state", GetTokenCtor(typeof(TokenKwState))); | ||
1063 | kws.Add("string", GetTokenCtor(typeof(TokenTypeStr))); | ||
1064 | kws.Add("vector", GetTokenCtor(typeof(TokenTypeVec))); | ||
1065 | kws.Add("while", GetTokenCtor(typeof(TokenKwWhile))); | ||
1066 | |||
1067 | return kws; | ||
1068 | } | ||
1069 | |||
1070 | private static Dictionary<string, System.Reflection.ConstructorInfo> BuildArrayKeywords() | ||
1071 | { | ||
1072 | Dictionary<string, System.Reflection.ConstructorInfo> kws = new Dictionary<string, System.Reflection.ConstructorInfo>(); | ||
1073 | |||
1074 | kws.Add("array", GetTokenCtor(typeof(TokenTypeArray))); | ||
1075 | kws.Add("foreach", GetTokenCtor(typeof(TokenKwForEach))); | ||
1076 | kws.Add("in", GetTokenCtor(typeof(TokenKwIn))); | ||
1077 | kws.Add("is", GetTokenCtor(typeof(TokenKwIs))); | ||
1078 | kws.Add("object", GetTokenCtor(typeof(TokenTypeObject))); | ||
1079 | kws.Add("undef", GetTokenCtor(typeof(TokenKwUndef))); | ||
1080 | |||
1081 | return kws; | ||
1082 | } | ||
1083 | |||
1084 | private static Dictionary<string, System.Reflection.ConstructorInfo> BuildAdvFlowCtlKeywords() | ||
1085 | { | ||
1086 | Dictionary<string, System.Reflection.ConstructorInfo> kws = new Dictionary<string, System.Reflection.ConstructorInfo>(); | ||
1087 | |||
1088 | kws.Add("break", GetTokenCtor(typeof(TokenKwBreak))); | ||
1089 | kws.Add("case", GetTokenCtor(typeof(TokenKwCase))); | ||
1090 | kws.Add("constant", GetTokenCtor(typeof(TokenKwConst))); | ||
1091 | kws.Add("continue", GetTokenCtor(typeof(TokenKwCont))); | ||
1092 | kws.Add("switch", GetTokenCtor(typeof(TokenKwSwitch))); | ||
1093 | |||
1094 | return kws; | ||
1095 | } | ||
1096 | |||
1097 | private static Dictionary<string, System.Reflection.ConstructorInfo> BuildTryCatchKeywords() | ||
1098 | { | ||
1099 | Dictionary<string, System.Reflection.ConstructorInfo> kws = new Dictionary<string, System.Reflection.ConstructorInfo>(); | ||
1100 | |||
1101 | kws.Add("catch", GetTokenCtor(typeof(TokenKwCatch))); | ||
1102 | kws.Add("exception", GetTokenCtor(typeof(TokenTypeExc))); | ||
1103 | kws.Add("finally", GetTokenCtor(typeof(TokenKwFinally))); | ||
1104 | kws.Add("throw", GetTokenCtor(typeof(TokenKwThrow))); | ||
1105 | kws.Add("try", GetTokenCtor(typeof(TokenKwTry))); | ||
1106 | |||
1107 | return kws; | ||
1108 | } | ||
1109 | |||
1110 | private static Dictionary<string, System.Reflection.ConstructorInfo> BuildObjectsKeywords() | ||
1111 | { | ||
1112 | Dictionary<string, System.Reflection.ConstructorInfo> kws = new Dictionary<string, System.Reflection.ConstructorInfo>(); | ||
1113 | |||
1114 | kws.Add("abstract", GetTokenCtor(typeof(TokenKwAbstract))); | ||
1115 | kws.Add("base", GetTokenCtor(typeof(TokenKwBase))); | ||
1116 | kws.Add("class", GetTokenCtor(typeof(TokenKwClass))); | ||
1117 | kws.Add("constructor", GetTokenCtor(typeof(TokenKwConstructor))); | ||
1118 | kws.Add("delegate", GetTokenCtor(typeof(TokenKwDelegate))); | ||
1119 | kws.Add("destructor", GetTokenCtor(typeof(TokenKwDestructor))); | ||
1120 | kws.Add("final", GetTokenCtor(typeof(TokenKwFinal))); | ||
1121 | kws.Add("get", GetTokenCtor(typeof(TokenKwGet))); | ||
1122 | kws.Add("interface", GetTokenCtor(typeof(TokenKwInterface))); | ||
1123 | kws.Add("new", GetTokenCtor(typeof(TokenKwNew))); | ||
1124 | kws.Add("override", GetTokenCtor(typeof(TokenKwOverride))); | ||
1125 | kws.Add("partial", GetTokenCtor(typeof(TokenKwPartial))); | ||
1126 | kws.Add("private", GetTokenCtor(typeof(TokenKwPrivate))); | ||
1127 | kws.Add("protected", GetTokenCtor(typeof(TokenKwProtected))); | ||
1128 | kws.Add("public", GetTokenCtor(typeof(TokenKwPublic))); | ||
1129 | kws.Add("set", GetTokenCtor(typeof(TokenKwSet))); | ||
1130 | kws.Add("static", GetTokenCtor(typeof(TokenKwStatic))); | ||
1131 | kws.Add("this", GetTokenCtor(typeof(TokenKwThis))); | ||
1132 | kws.Add("typedef", GetTokenCtor(typeof(TokenKwTypedef))); | ||
1133 | kws.Add("virtual", GetTokenCtor(typeof(TokenKwVirtual))); | ||
1134 | |||
1135 | return kws; | ||
1136 | } | ||
1137 | |||
1138 | private static Dictionary<string, System.Reflection.ConstructorInfo> BuildCharsKeywords() | ||
1139 | { | ||
1140 | Dictionary<string, System.Reflection.ConstructorInfo> kws = new Dictionary<string, System.Reflection.ConstructorInfo>(); | ||
1141 | |||
1142 | kws.Add("char", GetTokenCtor(typeof(TokenTypeChar))); | ||
1143 | |||
1144 | return kws; | ||
1145 | } | ||
1146 | } | ||
1147 | |||
1148 | /** | ||
1149 | * @brief All output token types in addition to TokenBegin. | ||
1150 | * They are all sub-types of Token. | ||
1151 | */ | ||
1152 | |||
1153 | public class TokenChar: Token | ||
1154 | { | ||
1155 | public char val; | ||
1156 | public TokenChar(TokenErrorMessage emsg, string file, int line, int posn, char val) : base(emsg, file, line, posn) | ||
1157 | { | ||
1158 | this.val = val; | ||
1159 | } | ||
1160 | public TokenChar(Token original, char val) : base(original) | ||
1161 | { | ||
1162 | this.val = val; | ||
1163 | } | ||
1164 | public override string ToString() | ||
1165 | { | ||
1166 | switch(val) | ||
1167 | { | ||
1168 | case '\'': | ||
1169 | return "'\\''"; | ||
1170 | case '\\': | ||
1171 | return "'\\\\'"; | ||
1172 | case '\n': | ||
1173 | return "'\\n'"; | ||
1174 | case '\t': | ||
1175 | return "'\\t'"; | ||
1176 | default: | ||
1177 | return "'" + val + "'"; | ||
1178 | } | ||
1179 | } | ||
1180 | } | ||
1181 | |||
1182 | public class TokenFloat: Token | ||
1183 | { | ||
1184 | public double val; | ||
1185 | public TokenFloat(TokenErrorMessage emsg, string file, int line, int posn, double val) : base(emsg, file, line, posn) | ||
1186 | { | ||
1187 | this.val = val; | ||
1188 | } | ||
1189 | public override string ToString() | ||
1190 | { | ||
1191 | return val.ToString(); | ||
1192 | } | ||
1193 | } | ||
1194 | |||
1195 | public class TokenInt: Token | ||
1196 | { | ||
1197 | public int val; | ||
1198 | public TokenInt(TokenErrorMessage emsg, string file, int line, int posn, int val) : base(emsg, file, line, posn) | ||
1199 | { | ||
1200 | this.val = val; | ||
1201 | } | ||
1202 | public TokenInt(Token original, int val) : base(original) | ||
1203 | { | ||
1204 | this.val = val; | ||
1205 | } | ||
1206 | public override string ToString() | ||
1207 | { | ||
1208 | return val.ToString(); | ||
1209 | } | ||
1210 | } | ||
1211 | |||
1212 | public class TokenName: Token | ||
1213 | { | ||
1214 | public string val; | ||
1215 | public TokenName(TokenErrorMessage emsg, string file, int line, int posn, string val) : base(emsg, file, line, posn) | ||
1216 | { | ||
1217 | this.val = val; | ||
1218 | } | ||
1219 | public TokenName(Token original, string val) : base(original) | ||
1220 | { | ||
1221 | this.val = val; | ||
1222 | } | ||
1223 | public override string ToString() | ||
1224 | { | ||
1225 | return this.val; | ||
1226 | } | ||
1227 | } | ||
1228 | |||
1229 | public class TokenStr: Token | ||
1230 | { | ||
1231 | public string val; | ||
1232 | public TokenStr(TokenErrorMessage emsg, string file, int line, int posn, string val) : base(emsg, file, line, posn) | ||
1233 | { | ||
1234 | this.val = val; | ||
1235 | } | ||
1236 | public override string ToString() | ||
1237 | { | ||
1238 | if((val.IndexOf('"') < 0) && | ||
1239 | (val.IndexOf('\\') < 0) && | ||
1240 | (val.IndexOf('\n') < 0) && | ||
1241 | (val.IndexOf('\t') < 0)) | ||
1242 | return "\"" + val + "\""; | ||
1243 | |||
1244 | int len = val.Length; | ||
1245 | StringBuilder sb = new StringBuilder(len * 2 + 2); | ||
1246 | sb.Append('"'); | ||
1247 | for(int i = 0; i < len; i++) | ||
1248 | { | ||
1249 | char c = val[i]; | ||
1250 | switch(c) | ||
1251 | { | ||
1252 | case '"': | ||
1253 | { | ||
1254 | sb.Append('\\'); | ||
1255 | sb.Append('"'); | ||
1256 | break; | ||
1257 | } | ||
1258 | case '\\': | ||
1259 | { | ||
1260 | sb.Append('\\'); | ||
1261 | sb.Append('\\'); | ||
1262 | break; | ||
1263 | } | ||
1264 | case '\n': | ||
1265 | { | ||
1266 | sb.Append('\\'); | ||
1267 | sb.Append('n'); | ||
1268 | break; | ||
1269 | } | ||
1270 | case '\t': | ||
1271 | { | ||
1272 | sb.Append('\\'); | ||
1273 | sb.Append('t'); | ||
1274 | break; | ||
1275 | } | ||
1276 | default: | ||
1277 | { | ||
1278 | sb.Append(c); | ||
1279 | break; | ||
1280 | } | ||
1281 | } | ||
1282 | } | ||
1283 | return sb.ToString(); | ||
1284 | } | ||
1285 | } | ||
1286 | |||
1287 | /* | ||
1288 | * This one marks the end-of-file. | ||
1289 | */ | ||
1290 | public class TokenEnd: Token | ||
1291 | { | ||
1292 | public TokenEnd(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { } | ||
1293 | } | ||
1294 | |||
1295 | /* | ||
1296 | * Various keywords and delimeters. | ||
1297 | */ | ||
1298 | public delegate object TokenRValConstBinOpDelegate(object left, object right); | ||
1299 | public delegate object TokenRValConstUnOpDelegate(object right); | ||
1300 | |||
1301 | public class TokenKw: Token | ||
1302 | { | ||
1303 | public TokenRValConstBinOpDelegate binOpConst; | ||
1304 | public TokenRValConstUnOpDelegate unOpConst; | ||
1305 | public bool sdtClassOp; | ||
1306 | public TokenKw(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) | ||
1307 | { | ||
1308 | } | ||
1309 | public TokenKw(Token original) : base(original) | ||
1310 | { | ||
1311 | } | ||
1312 | } | ||
1313 | |||
1314 | public class TokenKwDotDotDot: TokenKw | ||
1315 | { | ||
1316 | public TokenKwDotDotDot(TokenErrorMessage emsg, string file, | ||
1317 | int line, int posn) : base(emsg, file, line, posn) | ||
1318 | { | ||
1319 | binOpConst = TokenRValConstOps.Null; | ||
1320 | unOpConst = TokenRValConstOps.Null; | ||
1321 | sdtClassOp = false; | ||
1322 | } | ||
1323 | public TokenKwDotDotDot(Token original) : base(original) | ||
1324 | { | ||
1325 | binOpConst = TokenRValConstOps.Null; | ||
1326 | unOpConst = TokenRValConstOps.Null; | ||
1327 | sdtClassOp = false; | ||
1328 | } | ||
1329 | public override string ToString() | ||
1330 | { | ||
1331 | return "..."; | ||
1332 | } | ||
1333 | } | ||
1334 | public class TokenKwAndAndAnd: TokenKw | ||
1335 | { | ||
1336 | public TokenKwAndAndAnd(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) | ||
1337 | { | ||
1338 | binOpConst = TokenRValConstOps.Null; | ||
1339 | unOpConst = TokenRValConstOps.Null; | ||
1340 | sdtClassOp = false; | ||
1341 | } | ||
1342 | public TokenKwAndAndAnd(Token original) : base(original) | ||
1343 | { | ||
1344 | binOpConst = TokenRValConstOps.Null; | ||
1345 | unOpConst = TokenRValConstOps.Null; | ||
1346 | sdtClassOp = false; | ||
1347 | } | ||
1348 | public override string ToString() | ||
1349 | { | ||
1350 | return "&&&"; | ||
1351 | } | ||
1352 | } | ||
1353 | public class TokenKwOrOrOr: TokenKw | ||
1354 | { | ||
1355 | public TokenKwOrOrOr(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) | ||
1356 | { | ||
1357 | binOpConst = TokenRValConstOps.Null; | ||
1358 | unOpConst = TokenRValConstOps.Null; | ||
1359 | sdtClassOp = false; | ||
1360 | } | ||
1361 | public TokenKwOrOrOr(Token original) : base(original) | ||
1362 | { | ||
1363 | binOpConst = TokenRValConstOps.Null; | ||
1364 | unOpConst = TokenRValConstOps.Null; | ||
1365 | sdtClassOp = false; | ||
1366 | } | ||
1367 | public override string ToString() | ||
1368 | { | ||
1369 | return "|||"; | ||
1370 | } | ||
1371 | } | ||
1372 | public class TokenKwAsnLSh: TokenKw | ||
1373 | { | ||
1374 | public TokenKwAsnLSh(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) | ||
1375 | { | ||
1376 | binOpConst = TokenRValConstOps.Null; | ||
1377 | unOpConst = TokenRValConstOps.Null; | ||
1378 | sdtClassOp = true; | ||
1379 | } | ||
1380 | public TokenKwAsnLSh(Token original) : base(original) | ||
1381 | { | ||
1382 | binOpConst = TokenRValConstOps.Null; | ||
1383 | unOpConst = TokenRValConstOps.Null; | ||
1384 | sdtClassOp = true; | ||
1385 | } | ||
1386 | public override string ToString() | ||
1387 | { | ||
1388 | return "<<="; | ||
1389 | } | ||
1390 | } | ||
1391 | public class TokenKwAsnRSh: TokenKw | ||
1392 | { | ||
1393 | public TokenKwAsnRSh(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1394 | public TokenKwAsnRSh(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1395 | public override string ToString() | ||
1396 | { | ||
1397 | return ">>="; | ||
1398 | } | ||
1399 | } | ||
1400 | public class TokenKwCmpLE: TokenKw | ||
1401 | { | ||
1402 | public TokenKwCmpLE(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1403 | public TokenKwCmpLE(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1404 | public override string ToString() | ||
1405 | { | ||
1406 | return "<="; | ||
1407 | } | ||
1408 | } | ||
1409 | public class TokenKwCmpGE: TokenKw | ||
1410 | { | ||
1411 | public TokenKwCmpGE(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1412 | public TokenKwCmpGE(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1413 | public override string ToString() | ||
1414 | { | ||
1415 | return ">="; | ||
1416 | } | ||
1417 | } | ||
1418 | public class TokenKwCmpEQ: TokenKw | ||
1419 | { | ||
1420 | public TokenKwCmpEQ(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1421 | public TokenKwCmpEQ(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1422 | public override string ToString() | ||
1423 | { | ||
1424 | return "=="; | ||
1425 | } | ||
1426 | } | ||
1427 | public class TokenKwCmpNE: TokenKw | ||
1428 | { | ||
1429 | public TokenKwCmpNE(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1430 | public TokenKwCmpNE(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1431 | public override string ToString() | ||
1432 | { | ||
1433 | return "!="; | ||
1434 | } | ||
1435 | } | ||
1436 | public class TokenKwIncr: TokenKw | ||
1437 | { | ||
1438 | public TokenKwIncr(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1439 | public TokenKwIncr(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1440 | public override string ToString() | ||
1441 | { | ||
1442 | return "++"; | ||
1443 | } | ||
1444 | } | ||
1445 | public class TokenKwDecr: TokenKw | ||
1446 | { | ||
1447 | public TokenKwDecr(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1448 | public TokenKwDecr(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1449 | public override string ToString() | ||
1450 | { | ||
1451 | return "--"; | ||
1452 | } | ||
1453 | } | ||
1454 | public class TokenKwAndAnd: TokenKw | ||
1455 | { | ||
1456 | public TokenKwAndAnd(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1457 | public TokenKwAndAnd(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1458 | public override string ToString() | ||
1459 | { | ||
1460 | return "&&"; | ||
1461 | } | ||
1462 | } | ||
1463 | public class TokenKwOrOr: TokenKw | ||
1464 | { | ||
1465 | public TokenKwOrOr(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1466 | public TokenKwOrOr(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1467 | public override string ToString() | ||
1468 | { | ||
1469 | return "||"; | ||
1470 | } | ||
1471 | } | ||
1472 | public class TokenKwAsnAdd: TokenKw | ||
1473 | { | ||
1474 | public TokenKwAsnAdd(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1475 | public TokenKwAsnAdd(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1476 | public override string ToString() | ||
1477 | { | ||
1478 | return "+="; | ||
1479 | } | ||
1480 | } | ||
1481 | public class TokenKwAsnAnd: TokenKw | ||
1482 | { | ||
1483 | public TokenKwAsnAnd(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1484 | public TokenKwAsnAnd(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1485 | public override string ToString() | ||
1486 | { | ||
1487 | return "&="; | ||
1488 | } | ||
1489 | } | ||
1490 | public class TokenKwAsnSub: TokenKw | ||
1491 | { | ||
1492 | public TokenKwAsnSub(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1493 | public TokenKwAsnSub(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1494 | public override string ToString() | ||
1495 | { | ||
1496 | return "-="; | ||
1497 | } | ||
1498 | } | ||
1499 | public class TokenKwAsnMul: TokenKw | ||
1500 | { | ||
1501 | public TokenKwAsnMul(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1502 | public TokenKwAsnMul(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1503 | public override string ToString() | ||
1504 | { | ||
1505 | return "*="; | ||
1506 | } | ||
1507 | } | ||
1508 | public class TokenKwAsnDiv: TokenKw | ||
1509 | { | ||
1510 | public TokenKwAsnDiv(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1511 | public TokenKwAsnDiv(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1512 | public override string ToString() | ||
1513 | { | ||
1514 | return "/="; | ||
1515 | } | ||
1516 | } | ||
1517 | public class TokenKwAsnMod: TokenKw | ||
1518 | { | ||
1519 | public TokenKwAsnMod(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1520 | public TokenKwAsnMod(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1521 | public override string ToString() | ||
1522 | { | ||
1523 | return "%="; | ||
1524 | } | ||
1525 | } | ||
1526 | public class TokenKwAsnOr: TokenKw | ||
1527 | { | ||
1528 | public TokenKwAsnOr(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1529 | public TokenKwAsnOr(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1530 | public override string ToString() | ||
1531 | { | ||
1532 | return "|="; | ||
1533 | } | ||
1534 | } | ||
1535 | public class TokenKwAsnXor: TokenKw | ||
1536 | { | ||
1537 | public TokenKwAsnXor(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1538 | public TokenKwAsnXor(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1539 | public override string ToString() | ||
1540 | { | ||
1541 | return "^="; | ||
1542 | } | ||
1543 | } | ||
1544 | public class TokenKwLSh: TokenKw | ||
1545 | { | ||
1546 | public TokenKwLSh(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.LSh; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1547 | public TokenKwLSh(Token original) : base(original) { binOpConst = TokenRValConstOps.LSh; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1548 | public override string ToString() | ||
1549 | { | ||
1550 | return "<<"; | ||
1551 | } | ||
1552 | } | ||
1553 | public class TokenKwRSh: TokenKw | ||
1554 | { | ||
1555 | public TokenKwRSh(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.RSh; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1556 | public TokenKwRSh(Token original) : base(original) { binOpConst = TokenRValConstOps.RSh; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1557 | public override string ToString() | ||
1558 | { | ||
1559 | return ">>"; | ||
1560 | } | ||
1561 | } | ||
1562 | public class TokenKwTilde: TokenKw | ||
1563 | { | ||
1564 | public TokenKwTilde(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Not; sdtClassOp = true; } | ||
1565 | public TokenKwTilde(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Not; sdtClassOp = true; } | ||
1566 | public override string ToString() | ||
1567 | { | ||
1568 | return "~"; | ||
1569 | } | ||
1570 | } | ||
1571 | public class TokenKwExclam: TokenKw | ||
1572 | { | ||
1573 | public TokenKwExclam(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1574 | public TokenKwExclam(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1575 | public override string ToString() | ||
1576 | { | ||
1577 | return "!"; | ||
1578 | } | ||
1579 | } | ||
1580 | public class TokenKwAt: TokenKw | ||
1581 | { | ||
1582 | public TokenKwAt(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1583 | public TokenKwAt(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1584 | public override string ToString() | ||
1585 | { | ||
1586 | return "@"; | ||
1587 | } | ||
1588 | } | ||
1589 | public class TokenKwMod: TokenKw | ||
1590 | { | ||
1591 | public TokenKwMod(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Mod; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1592 | public TokenKwMod(Token original) : base(original) { binOpConst = TokenRValConstOps.Mod; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1593 | public override string ToString() | ||
1594 | { | ||
1595 | return "%"; | ||
1596 | } | ||
1597 | } | ||
1598 | public class TokenKwXor: TokenKw | ||
1599 | { | ||
1600 | public TokenKwXor(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Xor; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1601 | public TokenKwXor(Token original) : base(original) { binOpConst = TokenRValConstOps.Xor; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1602 | public override string ToString() | ||
1603 | { | ||
1604 | return "^"; | ||
1605 | } | ||
1606 | } | ||
1607 | public class TokenKwAnd: TokenKw | ||
1608 | { | ||
1609 | public TokenKwAnd(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.And; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1610 | public TokenKwAnd(Token original) : base(original) { binOpConst = TokenRValConstOps.And; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1611 | public override string ToString() | ||
1612 | { | ||
1613 | return "&"; | ||
1614 | } | ||
1615 | } | ||
1616 | public class TokenKwMul: TokenKw | ||
1617 | { | ||
1618 | public TokenKwMul(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Mul; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1619 | public TokenKwMul(Token original) : base(original) { binOpConst = TokenRValConstOps.Mul; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1620 | public override string ToString() | ||
1621 | { | ||
1622 | return "*"; | ||
1623 | } | ||
1624 | } | ||
1625 | public class TokenKwParOpen: TokenKw | ||
1626 | { | ||
1627 | public TokenKwParOpen(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1628 | public TokenKwParOpen(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1629 | public override string ToString() | ||
1630 | { | ||
1631 | return "("; | ||
1632 | } | ||
1633 | } | ||
1634 | public class TokenKwParClose: TokenKw | ||
1635 | { | ||
1636 | public TokenKwParClose(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1637 | public TokenKwParClose(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1638 | public override string ToString() | ||
1639 | { | ||
1640 | return ")"; | ||
1641 | } | ||
1642 | } | ||
1643 | public class TokenKwSub: TokenKw | ||
1644 | { | ||
1645 | public TokenKwSub(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Sub; unOpConst = TokenRValConstOps.Neg; sdtClassOp = true; } | ||
1646 | public TokenKwSub(Token original) : base(original) { binOpConst = TokenRValConstOps.Sub; unOpConst = TokenRValConstOps.Neg; sdtClassOp = true; } | ||
1647 | public override string ToString() | ||
1648 | { | ||
1649 | return "-"; | ||
1650 | } | ||
1651 | } | ||
1652 | public class TokenKwAdd: TokenKw | ||
1653 | { | ||
1654 | public TokenKwAdd(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Add; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1655 | public TokenKwAdd(Token original) : base(original) { binOpConst = TokenRValConstOps.Add; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1656 | public override string ToString() | ||
1657 | { | ||
1658 | return "+"; | ||
1659 | } | ||
1660 | } | ||
1661 | public class TokenKwAssign: TokenKw | ||
1662 | { | ||
1663 | public TokenKwAssign(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1664 | public TokenKwAssign(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1665 | public override string ToString() | ||
1666 | { | ||
1667 | return "="; | ||
1668 | } | ||
1669 | } | ||
1670 | public class TokenKwBrcOpen: TokenKw | ||
1671 | { | ||
1672 | public TokenKwBrcOpen(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1673 | public TokenKwBrcOpen(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1674 | public override string ToString() | ||
1675 | { | ||
1676 | return "{"; | ||
1677 | } | ||
1678 | } | ||
1679 | public class TokenKwBrcClose: TokenKw | ||
1680 | { | ||
1681 | public TokenKwBrcClose(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1682 | public TokenKwBrcClose(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1683 | public override string ToString() | ||
1684 | { | ||
1685 | return "}"; | ||
1686 | } | ||
1687 | } | ||
1688 | public class TokenKwBrkOpen: TokenKw | ||
1689 | { | ||
1690 | public TokenKwBrkOpen(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1691 | public TokenKwBrkOpen(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1692 | public override string ToString() | ||
1693 | { | ||
1694 | return "["; | ||
1695 | } | ||
1696 | } | ||
1697 | public class TokenKwBrkClose: TokenKw | ||
1698 | { | ||
1699 | public TokenKwBrkClose(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1700 | public TokenKwBrkClose(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1701 | public override string ToString() | ||
1702 | { | ||
1703 | return "]"; | ||
1704 | } | ||
1705 | } | ||
1706 | public class TokenKwSemi: TokenKw | ||
1707 | { | ||
1708 | public TokenKwSemi(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1709 | public TokenKwSemi(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1710 | public override string ToString() | ||
1711 | { | ||
1712 | return ";"; | ||
1713 | } | ||
1714 | } | ||
1715 | public class TokenKwColon: TokenKw | ||
1716 | { | ||
1717 | public TokenKwColon(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1718 | public TokenKwColon(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1719 | public override string ToString() | ||
1720 | { | ||
1721 | return ":"; | ||
1722 | } | ||
1723 | } | ||
1724 | public class TokenKwCmpLT: TokenKw | ||
1725 | { | ||
1726 | public TokenKwCmpLT(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1727 | public TokenKwCmpLT(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1728 | public override string ToString() | ||
1729 | { | ||
1730 | return "<"; | ||
1731 | } | ||
1732 | } | ||
1733 | public class TokenKwCmpGT: TokenKw | ||
1734 | { | ||
1735 | public TokenKwCmpGT(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1736 | public TokenKwCmpGT(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1737 | public override string ToString() | ||
1738 | { | ||
1739 | return ">"; | ||
1740 | } | ||
1741 | } | ||
1742 | public class TokenKwComma: TokenKw | ||
1743 | { | ||
1744 | public TokenKwComma(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1745 | public TokenKwComma(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1746 | public override string ToString() | ||
1747 | { | ||
1748 | return ","; | ||
1749 | } | ||
1750 | } | ||
1751 | public class TokenKwDot: TokenKw | ||
1752 | { | ||
1753 | public TokenKwDot(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1754 | public TokenKwDot(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1755 | public override string ToString() | ||
1756 | { | ||
1757 | return "."; | ||
1758 | } | ||
1759 | } | ||
1760 | public class TokenKwQMark: TokenKw | ||
1761 | { | ||
1762 | public TokenKwQMark(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1763 | public TokenKwQMark(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1764 | public override string ToString() | ||
1765 | { | ||
1766 | return "?"; | ||
1767 | } | ||
1768 | } | ||
1769 | public class TokenKwDiv: TokenKw | ||
1770 | { | ||
1771 | public TokenKwDiv(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Div; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1772 | public TokenKwDiv(Token original) : base(original) { binOpConst = TokenRValConstOps.Div; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1773 | public override string ToString() | ||
1774 | { | ||
1775 | return "/"; | ||
1776 | } | ||
1777 | } | ||
1778 | public class TokenKwOr: TokenKw | ||
1779 | { | ||
1780 | public TokenKwOr(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Or; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1781 | public TokenKwOr(Token original) : base(original) { binOpConst = TokenRValConstOps.Or; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | ||
1782 | public override string ToString() | ||
1783 | { | ||
1784 | return "|"; | ||
1785 | } | ||
1786 | } | ||
1787 | public class TokenKwHash: TokenKw | ||
1788 | { | ||
1789 | public TokenKwHash(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1790 | public TokenKwHash(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1791 | public override string ToString() | ||
1792 | { | ||
1793 | return "#"; | ||
1794 | } | ||
1795 | } | ||
1796 | |||
1797 | public class TokenKwAbstract: TokenKw | ||
1798 | { | ||
1799 | public TokenKwAbstract(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1800 | public TokenKwAbstract(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1801 | public override string ToString() | ||
1802 | { | ||
1803 | return "abstract"; | ||
1804 | } | ||
1805 | } | ||
1806 | public class TokenKwBase: TokenKw | ||
1807 | { | ||
1808 | public TokenKwBase(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1809 | public TokenKwBase(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1810 | public override string ToString() | ||
1811 | { | ||
1812 | return "base"; | ||
1813 | } | ||
1814 | } | ||
1815 | public class TokenKwBreak: TokenKw | ||
1816 | { | ||
1817 | public TokenKwBreak(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1818 | public TokenKwBreak(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1819 | public override string ToString() | ||
1820 | { | ||
1821 | return "break"; | ||
1822 | } | ||
1823 | } | ||
1824 | public class TokenKwCase: TokenKw | ||
1825 | { | ||
1826 | public TokenKwCase(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1827 | public TokenKwCase(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1828 | public override string ToString() | ||
1829 | { | ||
1830 | return "case"; | ||
1831 | } | ||
1832 | } | ||
1833 | public class TokenKwCatch: TokenKw | ||
1834 | { | ||
1835 | public TokenKwCatch(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1836 | public TokenKwCatch(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1837 | public override string ToString() | ||
1838 | { | ||
1839 | return "catch"; | ||
1840 | } | ||
1841 | } | ||
1842 | public class TokenKwClass: TokenKw | ||
1843 | { | ||
1844 | public TokenKwClass(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1845 | public TokenKwClass(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1846 | public override string ToString() | ||
1847 | { | ||
1848 | return "class"; | ||
1849 | } | ||
1850 | } | ||
1851 | public class TokenKwConst: TokenKw | ||
1852 | { | ||
1853 | public TokenKwConst(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1854 | public TokenKwConst(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1855 | public override string ToString() | ||
1856 | { | ||
1857 | return "constant"; | ||
1858 | } | ||
1859 | } | ||
1860 | public class TokenKwConstructor: TokenKw | ||
1861 | { | ||
1862 | public TokenKwConstructor(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1863 | public TokenKwConstructor(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1864 | public override string ToString() | ||
1865 | { | ||
1866 | return "constructor"; | ||
1867 | } | ||
1868 | } | ||
1869 | public class TokenKwCont: TokenKw | ||
1870 | { | ||
1871 | public TokenKwCont(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1872 | public TokenKwCont(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1873 | public override string ToString() | ||
1874 | { | ||
1875 | return "continue"; | ||
1876 | } | ||
1877 | } | ||
1878 | public class TokenKwDelegate: TokenKw | ||
1879 | { | ||
1880 | public TokenKwDelegate(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1881 | public TokenKwDelegate(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1882 | public override string ToString() | ||
1883 | { | ||
1884 | return "delegate"; | ||
1885 | } | ||
1886 | } | ||
1887 | public class TokenKwDefault: TokenKw | ||
1888 | { | ||
1889 | public TokenKwDefault(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1890 | public TokenKwDefault(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1891 | public override string ToString() | ||
1892 | { | ||
1893 | return "default"; | ||
1894 | } | ||
1895 | } | ||
1896 | public class TokenKwDestructor: TokenKw | ||
1897 | { | ||
1898 | public TokenKwDestructor(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1899 | public TokenKwDestructor(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1900 | public override string ToString() | ||
1901 | { | ||
1902 | return "destructor"; | ||
1903 | } | ||
1904 | } | ||
1905 | public class TokenKwDo: TokenKw | ||
1906 | { | ||
1907 | public TokenKwDo(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1908 | public TokenKwDo(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1909 | public override string ToString() | ||
1910 | { | ||
1911 | return "do"; | ||
1912 | } | ||
1913 | } | ||
1914 | public class TokenKwElse: TokenKw | ||
1915 | { | ||
1916 | public TokenKwElse(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1917 | public TokenKwElse(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1918 | public override string ToString() | ||
1919 | { | ||
1920 | return "else"; | ||
1921 | } | ||
1922 | } | ||
1923 | public class TokenKwFinal: TokenKw | ||
1924 | { | ||
1925 | public TokenKwFinal(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1926 | public TokenKwFinal(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1927 | public override string ToString() | ||
1928 | { | ||
1929 | return "final"; | ||
1930 | } | ||
1931 | } | ||
1932 | public class TokenKwFinally: TokenKw | ||
1933 | { | ||
1934 | public TokenKwFinally(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1935 | public TokenKwFinally(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1936 | public override string ToString() | ||
1937 | { | ||
1938 | return "finally"; | ||
1939 | } | ||
1940 | } | ||
1941 | public class TokenKwFor: TokenKw | ||
1942 | { | ||
1943 | public TokenKwFor(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1944 | public TokenKwFor(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1945 | public override string ToString() | ||
1946 | { | ||
1947 | return "for"; | ||
1948 | } | ||
1949 | } | ||
1950 | public class TokenKwForEach: TokenKw | ||
1951 | { | ||
1952 | public TokenKwForEach(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1953 | public TokenKwForEach(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1954 | public override string ToString() | ||
1955 | { | ||
1956 | return "foreach"; | ||
1957 | } | ||
1958 | } | ||
1959 | public class TokenKwGet: TokenKw | ||
1960 | { | ||
1961 | public TokenKwGet(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1962 | public TokenKwGet(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1963 | public override string ToString() | ||
1964 | { | ||
1965 | return "get"; | ||
1966 | } | ||
1967 | } | ||
1968 | public class TokenKwIf: TokenKw | ||
1969 | { | ||
1970 | public TokenKwIf(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1971 | public TokenKwIf(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1972 | public override string ToString() | ||
1973 | { | ||
1974 | return "if"; | ||
1975 | } | ||
1976 | } | ||
1977 | public class TokenKwIn: TokenKw | ||
1978 | { | ||
1979 | public TokenKwIn(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1980 | public TokenKwIn(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1981 | public override string ToString() | ||
1982 | { | ||
1983 | return "in"; | ||
1984 | } | ||
1985 | } | ||
1986 | public class TokenKwInterface: TokenKw | ||
1987 | { | ||
1988 | public TokenKwInterface(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1989 | public TokenKwInterface(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1990 | public override string ToString() | ||
1991 | { | ||
1992 | return "interface"; | ||
1993 | } | ||
1994 | } | ||
1995 | public class TokenKwIs: TokenKw | ||
1996 | { | ||
1997 | public TokenKwIs(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1998 | public TokenKwIs(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
1999 | public override string ToString() | ||
2000 | { | ||
2001 | return "is"; | ||
2002 | } | ||
2003 | } | ||
2004 | public class TokenKwJump: TokenKw | ||
2005 | { | ||
2006 | public TokenKwJump(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2007 | public TokenKwJump(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2008 | public override string ToString() | ||
2009 | { | ||
2010 | return "jump"; | ||
2011 | } | ||
2012 | } | ||
2013 | public class TokenKwNew: TokenKw | ||
2014 | { | ||
2015 | public TokenKwNew(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2016 | public TokenKwNew(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2017 | public override string ToString() | ||
2018 | { | ||
2019 | return "new"; | ||
2020 | } | ||
2021 | } | ||
2022 | public class TokenKwOverride: TokenKw | ||
2023 | { | ||
2024 | public TokenKwOverride(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2025 | public TokenKwOverride(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2026 | public override string ToString() | ||
2027 | { | ||
2028 | return "override"; | ||
2029 | } | ||
2030 | } | ||
2031 | public class TokenKwPartial: TokenKw | ||
2032 | { | ||
2033 | public TokenKwPartial(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2034 | public TokenKwPartial(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2035 | public override string ToString() | ||
2036 | { | ||
2037 | return "partial"; | ||
2038 | } | ||
2039 | } | ||
2040 | public class TokenKwPrivate: TokenKw | ||
2041 | { | ||
2042 | public TokenKwPrivate(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2043 | public TokenKwPrivate(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2044 | public override string ToString() | ||
2045 | { | ||
2046 | return "private"; | ||
2047 | } | ||
2048 | } | ||
2049 | public class TokenKwProtected: TokenKw | ||
2050 | { | ||
2051 | public TokenKwProtected(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2052 | public TokenKwProtected(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2053 | public override string ToString() | ||
2054 | { | ||
2055 | return "protected"; | ||
2056 | } | ||
2057 | } | ||
2058 | public class TokenKwPublic: TokenKw | ||
2059 | { | ||
2060 | public TokenKwPublic(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2061 | public TokenKwPublic(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2062 | public override string ToString() | ||
2063 | { | ||
2064 | return "public"; | ||
2065 | } | ||
2066 | } | ||
2067 | public class TokenKwRet: TokenKw | ||
2068 | { | ||
2069 | public TokenKwRet(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2070 | public TokenKwRet(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2071 | public override string ToString() | ||
2072 | { | ||
2073 | return "return"; | ||
2074 | } | ||
2075 | } | ||
2076 | public class TokenKwSet: TokenKw | ||
2077 | { | ||
2078 | public TokenKwSet(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2079 | public TokenKwSet(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2080 | public override string ToString() | ||
2081 | { | ||
2082 | return "set"; | ||
2083 | } | ||
2084 | } | ||
2085 | public class TokenKwState: TokenKw | ||
2086 | { | ||
2087 | public TokenKwState(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2088 | public TokenKwState(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2089 | public override string ToString() | ||
2090 | { | ||
2091 | return "state"; | ||
2092 | } | ||
2093 | } | ||
2094 | public class TokenKwStatic: TokenKw | ||
2095 | { | ||
2096 | public TokenKwStatic(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2097 | public TokenKwStatic(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2098 | public override string ToString() | ||
2099 | { | ||
2100 | return "static"; | ||
2101 | } | ||
2102 | } | ||
2103 | public class TokenKwSwitch: TokenKw | ||
2104 | { | ||
2105 | public TokenKwSwitch(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2106 | public TokenKwSwitch(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2107 | public override string ToString() | ||
2108 | { | ||
2109 | return "switch"; | ||
2110 | } | ||
2111 | } | ||
2112 | public class TokenKwThis: TokenKw | ||
2113 | { | ||
2114 | public TokenKwThis(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2115 | public TokenKwThis(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2116 | public override string ToString() | ||
2117 | { | ||
2118 | return "this"; | ||
2119 | } | ||
2120 | } | ||
2121 | public class TokenKwThrow: TokenKw | ||
2122 | { | ||
2123 | public TokenKwThrow(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2124 | public TokenKwThrow(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2125 | public override string ToString() | ||
2126 | { | ||
2127 | return "throw"; | ||
2128 | } | ||
2129 | } | ||
2130 | public class TokenKwTry: TokenKw | ||
2131 | { | ||
2132 | public TokenKwTry(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2133 | public TokenKwTry(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2134 | public override string ToString() | ||
2135 | { | ||
2136 | return "try"; | ||
2137 | } | ||
2138 | } | ||
2139 | public class TokenKwTypedef: TokenKw | ||
2140 | { | ||
2141 | public TokenKwTypedef(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2142 | public TokenKwTypedef(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2143 | public override string ToString() | ||
2144 | { | ||
2145 | return "typedef"; | ||
2146 | } | ||
2147 | } | ||
2148 | public class TokenKwUndef: TokenKw | ||
2149 | { | ||
2150 | public TokenKwUndef(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2151 | public TokenKwUndef(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2152 | public override string ToString() | ||
2153 | { | ||
2154 | return "undef"; | ||
2155 | } | ||
2156 | } | ||
2157 | public class TokenKwVirtual: TokenKw | ||
2158 | { | ||
2159 | public TokenKwVirtual(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2160 | public TokenKwVirtual(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2161 | public override string ToString() | ||
2162 | { | ||
2163 | return "virtual"; | ||
2164 | } | ||
2165 | } | ||
2166 | public class TokenKwWhile: TokenKw | ||
2167 | { | ||
2168 | public TokenKwWhile(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2169 | public TokenKwWhile(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = false; } | ||
2170 | public override string ToString() | ||
2171 | { | ||
2172 | return "while"; | ||
2173 | } | ||
2174 | } | ||
2175 | |||
2176 | /** | ||
2177 | * @brief These static functions attempt to perform arithmetic on two constant | ||
2178 | * operands to generate the resultant constant. | ||
2179 | * Likewise for unary operators. | ||
2180 | * | ||
2181 | * @param left = left-hand value | ||
2182 | * @param right = right-hand value | ||
2183 | * @returns null: not able to perform computation | ||
2184 | * else: resultant value object | ||
2185 | * | ||
2186 | * Note: it is ok for these to throw any exception (such as overflow or div-by-zero), | ||
2187 | * and it will be treated as the 'not able to perform computation' case. | ||
2188 | */ | ||
2189 | public class TokenRValConstOps | ||
2190 | { | ||
2191 | public static object Null(object left, object right) | ||
2192 | { | ||
2193 | return null; | ||
2194 | } | ||
2195 | public static object Div(object left, object right) | ||
2196 | { | ||
2197 | if((left is int) && (right is int)) | ||
2198 | { | ||
2199 | return (int)left / (int)right; | ||
2200 | } | ||
2201 | if((left is int) && (right is double)) | ||
2202 | { | ||
2203 | return (int)left / (double)right; | ||
2204 | } | ||
2205 | if((left is double) && (right is int)) | ||
2206 | { | ||
2207 | return (double)left / (int)right; | ||
2208 | } | ||
2209 | if((left is double) && (right is double)) | ||
2210 | { | ||
2211 | return (double)left / (double)right; | ||
2212 | } | ||
2213 | return null; | ||
2214 | } | ||
2215 | public static object Mod(object left, object right) | ||
2216 | { | ||
2217 | if((left is int) && (right is int)) | ||
2218 | { | ||
2219 | return (int)left % (int)right; | ||
2220 | } | ||
2221 | if((left is int) && (right is double)) | ||
2222 | { | ||
2223 | return (int)left % (double)right; | ||
2224 | } | ||
2225 | if((left is double) && (right is int)) | ||
2226 | { | ||
2227 | return (double)left % (int)right; | ||
2228 | } | ||
2229 | if((left is double) && (right is double)) | ||
2230 | { | ||
2231 | return (double)left % (double)right; | ||
2232 | } | ||
2233 | return null; | ||
2234 | } | ||
2235 | public static object Mul(object left, object right) | ||
2236 | { | ||
2237 | if((left is int) && (right is int)) | ||
2238 | { | ||
2239 | return (int)left * (int)right; | ||
2240 | } | ||
2241 | if((left is int) && (right is double)) | ||
2242 | { | ||
2243 | return (int)left * (double)right; | ||
2244 | } | ||
2245 | if((left is double) && (right is int)) | ||
2246 | { | ||
2247 | return (double)left * (int)right; | ||
2248 | } | ||
2249 | if((left is double) && (right is double)) | ||
2250 | { | ||
2251 | return (double)left * (double)right; | ||
2252 | } | ||
2253 | return null; | ||
2254 | } | ||
2255 | public static object And(object left, object right) | ||
2256 | { | ||
2257 | if((left is int) && (right is int)) | ||
2258 | { | ||
2259 | return (int)left & (int)right; | ||
2260 | } | ||
2261 | if((left is int) && (right is double)) | ||
2262 | { | ||
2263 | return (int)left & (int)(double)right; | ||
2264 | } | ||
2265 | if((left is double) && (right is int)) | ||
2266 | { | ||
2267 | return (int)(double)left & (int)right; | ||
2268 | } | ||
2269 | if((left is double) && (right is double)) | ||
2270 | { | ||
2271 | return (int)(double)left & (int)(double)right; | ||
2272 | } | ||
2273 | return null; | ||
2274 | } | ||
2275 | public static object LSh(object left, object right) | ||
2276 | { | ||
2277 | if((left is int) && (right is int)) | ||
2278 | { | ||
2279 | return (int)left << (int)right; | ||
2280 | } | ||
2281 | if((left is int) && (right is double)) | ||
2282 | { | ||
2283 | return (int)left << (int)(double)right; | ||
2284 | } | ||
2285 | if((left is double) && (right is int)) | ||
2286 | { | ||
2287 | return (int)(double)left << (int)right; | ||
2288 | } | ||
2289 | if((left is double) && (right is double)) | ||
2290 | { | ||
2291 | return (int)(double)left << (int)(double)right; | ||
2292 | } | ||
2293 | return null; | ||
2294 | } | ||
2295 | public static object Or(object left, object right) | ||
2296 | { | ||
2297 | if((left is int) && (right is int)) | ||
2298 | { | ||
2299 | return (int)left | (int)right; | ||
2300 | } | ||
2301 | if((left is int) && (right is double)) | ||
2302 | { | ||
2303 | return (int)left | (int)(double)right; | ||
2304 | } | ||
2305 | if((left is double) && (right is int)) | ||
2306 | { | ||
2307 | return (int)(double)left | (int)right; | ||
2308 | } | ||
2309 | if((left is double) && (right is double)) | ||
2310 | { | ||
2311 | return (int)(double)left | (int)(double)right; | ||
2312 | } | ||
2313 | return null; | ||
2314 | } | ||
2315 | public static object RSh(object left, object right) | ||
2316 | { | ||
2317 | if((left is int) && (right is int)) | ||
2318 | { | ||
2319 | return (int)left >> (int)right; | ||
2320 | } | ||
2321 | if((left is int) && (right is double)) | ||
2322 | { | ||
2323 | return (int)left >> (int)(double)right; | ||
2324 | } | ||
2325 | if((left is double) && (right is int)) | ||
2326 | { | ||
2327 | return (int)(double)left >> (int)right; | ||
2328 | } | ||
2329 | if((left is double) && (right is double)) | ||
2330 | { | ||
2331 | return (int)(double)left >> (int)(double)right; | ||
2332 | } | ||
2333 | return null; | ||
2334 | } | ||
2335 | public static object Xor(object left, object right) | ||
2336 | { | ||
2337 | if((left is int) && (right is int)) | ||
2338 | { | ||
2339 | return (int)left ^ (int)right; | ||
2340 | } | ||
2341 | if((left is int) && (right is double)) | ||
2342 | { | ||
2343 | return (int)left ^ (int)(double)right; | ||
2344 | } | ||
2345 | if((left is double) && (right is int)) | ||
2346 | { | ||
2347 | return (int)(double)left ^ (int)right; | ||
2348 | } | ||
2349 | if((left is double) && (right is double)) | ||
2350 | { | ||
2351 | return (int)(double)left ^ (int)(double)right; | ||
2352 | } | ||
2353 | return null; | ||
2354 | } | ||
2355 | public static object Add(object left, object right) | ||
2356 | { | ||
2357 | if((left is char) && (right is int)) | ||
2358 | { | ||
2359 | return (char)((char)left + (int)right); | ||
2360 | } | ||
2361 | if((left is double) && (right is double)) | ||
2362 | { | ||
2363 | return (double)left + (double)right; | ||
2364 | } | ||
2365 | if((left is double) && (right is int)) | ||
2366 | { | ||
2367 | return (double)left + (int)right; | ||
2368 | } | ||
2369 | if((left is double) && (right is string)) | ||
2370 | { | ||
2371 | return TypeCast.FloatToString((double)left) + (string)right; | ||
2372 | } | ||
2373 | if((left is int) && (right is double)) | ||
2374 | { | ||
2375 | return (int)left + (double)right; | ||
2376 | } | ||
2377 | if((left is int) && (right is int)) | ||
2378 | { | ||
2379 | return (int)left + (int)right; | ||
2380 | } | ||
2381 | if((left is int) && (right is string)) | ||
2382 | { | ||
2383 | return TypeCast.IntegerToString((int)left) + (string)right; | ||
2384 | } | ||
2385 | if((left is string) && (right is char)) | ||
2386 | { | ||
2387 | return (string)left + (char)right; | ||
2388 | } | ||
2389 | if((left is string) && (right is double)) | ||
2390 | { | ||
2391 | return (string)left + TypeCast.FloatToString((double)right); | ||
2392 | } | ||
2393 | if((left is string) && (right is int)) | ||
2394 | { | ||
2395 | return (string)left + TypeCast.IntegerToString((int)right); | ||
2396 | } | ||
2397 | if((left is string) && (right is string)) | ||
2398 | { | ||
2399 | return (string)left + (string)right; | ||
2400 | } | ||
2401 | return null; | ||
2402 | } | ||
2403 | public static object Sub(object left, object right) | ||
2404 | { | ||
2405 | if((left is char) && (right is int)) | ||
2406 | { | ||
2407 | return (char)((char)left - (int)right); | ||
2408 | } | ||
2409 | if((left is int) && (right is int)) | ||
2410 | { | ||
2411 | return (int)left - (int)right; | ||
2412 | } | ||
2413 | if((left is int) && (right is double)) | ||
2414 | { | ||
2415 | return (int)left - (double)right; | ||
2416 | } | ||
2417 | if((left is double) && (right is int)) | ||
2418 | { | ||
2419 | return (double)left - (int)right; | ||
2420 | } | ||
2421 | if((left is double) && (right is double)) | ||
2422 | { | ||
2423 | return (double)left - (double)right; | ||
2424 | } | ||
2425 | return null; | ||
2426 | } | ||
2427 | public static object Null(object right) | ||
2428 | { | ||
2429 | return null; | ||
2430 | } | ||
2431 | public static object Neg(object right) | ||
2432 | { | ||
2433 | if(right is int) | ||
2434 | { | ||
2435 | return -(int)right; | ||
2436 | } | ||
2437 | if(right is double) | ||
2438 | { | ||
2439 | return -(double)right; | ||
2440 | } | ||
2441 | return null; | ||
2442 | } | ||
2443 | public static object Not(object right) | ||
2444 | { | ||
2445 | if(right is int) | ||
2446 | { | ||
2447 | return ~(int)right; | ||
2448 | } | ||
2449 | return null; | ||
2450 | } | ||
2451 | } | ||
2452 | |||
2453 | /* | ||
2454 | * Various datatypes. | ||
2455 | */ | ||
2456 | public abstract class TokenType: Token | ||
2457 | { | ||
2458 | |||
2459 | public TokenType(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { } | ||
2460 | public TokenType(Token original) : base(original) { } | ||
2461 | |||
2462 | public static TokenType FromSysType(Token original, System.Type typ) | ||
2463 | { | ||
2464 | if(typ == typeof(LSL_List)) | ||
2465 | return new TokenTypeList(original); | ||
2466 | if(typ == typeof(LSL_Rotation)) | ||
2467 | return new TokenTypeRot(original); | ||
2468 | if(typ == typeof(void)) | ||
2469 | return new TokenTypeVoid(original); | ||
2470 | if(typ == typeof(LSL_Vector)) | ||
2471 | return new TokenTypeVec(original); | ||
2472 | if(typ == typeof(float)) | ||
2473 | return new TokenTypeFloat(original); | ||
2474 | if(typ == typeof(int)) | ||
2475 | return new TokenTypeInt(original); | ||
2476 | if(typ == typeof(string)) | ||
2477 | return new TokenTypeStr(original); | ||
2478 | if(typ == typeof(double)) | ||
2479 | return new TokenTypeFloat(original); | ||
2480 | if(typ == typeof(bool)) | ||
2481 | return new TokenTypeBool(original); | ||
2482 | if(typ == typeof(object)) | ||
2483 | return new TokenTypeObject(original); | ||
2484 | if(typ == typeof(XMR_Array)) | ||
2485 | return new TokenTypeArray(original); | ||
2486 | if(typ == typeof(LSL_Integer)) | ||
2487 | return new TokenTypeLSLInt(original); | ||
2488 | if(typ == typeof(LSL_Float)) | ||
2489 | return new TokenTypeLSLFloat(original); | ||
2490 | if(typ == typeof(LSL_String)) | ||
2491 | return new TokenTypeLSLString(original); | ||
2492 | if(typ == typeof(char)) | ||
2493 | return new TokenTypeChar(original); | ||
2494 | if(typ == typeof(Exception)) | ||
2495 | return new TokenTypeExc(original); | ||
2496 | |||
2497 | throw new Exception("unknown script type " + typ.ToString()); | ||
2498 | } | ||
2499 | |||
2500 | public static TokenType FromLSLType(Token original, string typ) | ||
2501 | { | ||
2502 | if(typ == "list") | ||
2503 | return new TokenTypeList(original); | ||
2504 | if(typ == "rotation") | ||
2505 | return new TokenTypeRot(original); | ||
2506 | if(typ == "vector") | ||
2507 | return new TokenTypeVec(original); | ||
2508 | if(typ == "float") | ||
2509 | return new TokenTypeFloat(original); | ||
2510 | if(typ == "integer") | ||
2511 | return new TokenTypeInt(original); | ||
2512 | if(typ == "key") | ||
2513 | return new TokenTypeKey(original); | ||
2514 | if(typ == "string") | ||
2515 | return new TokenTypeStr(original); | ||
2516 | if(typ == "object") | ||
2517 | return new TokenTypeObject(original); | ||
2518 | if(typ == "array") | ||
2519 | return new TokenTypeArray(original); | ||
2520 | if(typ == "bool") | ||
2521 | return new TokenTypeBool(original); | ||
2522 | if(typ == "void") | ||
2523 | return new TokenTypeVoid(original); | ||
2524 | if(typ == "char") | ||
2525 | return new TokenTypeChar(original); | ||
2526 | if(typ == "exception") | ||
2527 | return new TokenTypeExc(original); | ||
2528 | |||
2529 | throw new Exception("unknown type " + typ); | ||
2530 | } | ||
2531 | |||
2532 | /** | ||
2533 | * @brief Estimate the number of bytes of memory taken by one of these | ||
2534 | * objects. For objects with widely varying size, return the | ||
2535 | * smallest it can be. | ||
2536 | */ | ||
2537 | public static int StaticSize(System.Type typ) | ||
2538 | { | ||
2539 | if(typ == typeof(LSL_List)) | ||
2540 | return 96; | ||
2541 | if(typ == typeof(LSL_Rotation)) | ||
2542 | return 80; | ||
2543 | if(typ == typeof(void)) | ||
2544 | return 0; | ||
2545 | if(typ == typeof(LSL_Vector)) | ||
2546 | return 72; | ||
2547 | if(typ == typeof(float)) | ||
2548 | return 8; | ||
2549 | if(typ == typeof(int)) | ||
2550 | return 8; | ||
2551 | if(typ == typeof(string)) | ||
2552 | return 40; | ||
2553 | if(typ == typeof(double)) | ||
2554 | return 8; | ||
2555 | if(typ == typeof(bool)) | ||
2556 | return 8; | ||
2557 | if(typ == typeof(XMR_Array)) | ||
2558 | return 96; | ||
2559 | if(typ == typeof(object)) | ||
2560 | return 32; | ||
2561 | if(typ == typeof(char)) | ||
2562 | return 2; | ||
2563 | |||
2564 | if(typ == typeof(LSL_Integer)) | ||
2565 | return 32; | ||
2566 | if(typ == typeof(LSL_Float)) | ||
2567 | return 32; | ||
2568 | if(typ == typeof(LSL_String)) | ||
2569 | return 40; | ||
2570 | |||
2571 | throw new Exception("unknown type " + typ.ToString()); | ||
2572 | } | ||
2573 | |||
2574 | /** | ||
2575 | * @brief Return the corresponding system type. | ||
2576 | */ | ||
2577 | public abstract Type ToSysType(); | ||
2578 | |||
2579 | /** | ||
2580 | * @brief Return the equivalent LSL wrapping type. | ||
2581 | * | ||
2582 | * null: normal | ||
2583 | * else: LSL-style wrapping, ie, LSL_Integer, LSL_Float, LSL_String | ||
2584 | * ToSysType()=System.Int32; lslWrapping=LSL_Integer | ||
2585 | * ToSysType()=System.Float; lslWrapping=LSL_Float | ||
2586 | * ToSysType()=System.String; lslWrapping=LSL_String | ||
2587 | */ | ||
2588 | public virtual Type ToLSLWrapType() | ||
2589 | { | ||
2590 | return null; | ||
2591 | } | ||
2592 | |||
2593 | /** | ||
2594 | * @brief Assign slots in either the global variable arrays or the script-defined type instance arrays. | ||
2595 | * These only need to be implemented for script-visible types, ie, those that a script writer | ||
2596 | * can actually define a variable as. | ||
2597 | */ | ||
2598 | public virtual void AssignVarSlot(TokenDeclVar declVar, XMRInstArSizes arSizes) | ||
2599 | { | ||
2600 | throw new Exception("not implemented for " + ToString() + " (" + GetType() + ")"); | ||
2601 | } | ||
2602 | |||
2603 | /** | ||
2604 | * @brief Get heap tracking type. | ||
2605 | * null indicates there is no heap tracker for the type. | ||
2606 | */ | ||
2607 | public virtual Type ToHeapTrackerType() | ||
2608 | { | ||
2609 | return null; | ||
2610 | } | ||
2611 | public virtual ConstructorInfo GetHeapTrackerCtor() | ||
2612 | { | ||
2613 | throw new ApplicationException("no GetHeapTrackerCtor for " + this.GetType()); | ||
2614 | } | ||
2615 | public virtual void CallHeapTrackerPopMeth(Token errorAt, ScriptMyILGen ilGen) | ||
2616 | { | ||
2617 | throw new ApplicationException("no CallHeapTrackerPopMeth for " + this.GetType()); | ||
2618 | } | ||
2619 | public virtual void CallHeapTrackerPushMeth(Token errorAt, ScriptMyILGen ilGen) | ||
2620 | { | ||
2621 | throw new ApplicationException("no CallHeapTrackerPushMeth for " + this.GetType()); | ||
2622 | } | ||
2623 | } | ||
2624 | |||
2625 | public class TokenTypeArray: TokenType | ||
2626 | { | ||
2627 | private static readonly FieldInfo iarArraysFieldInfo = typeof(XMRInstArrays).GetField("iarArrays"); | ||
2628 | |||
2629 | public TokenTypeArray(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { } | ||
2630 | public TokenTypeArray(Token original) : base(original) { } | ||
2631 | public override Type ToSysType() | ||
2632 | { | ||
2633 | return typeof(XMR_Array); | ||
2634 | } | ||
2635 | public override string ToString() | ||
2636 | { | ||
2637 | return "array"; | ||
2638 | } | ||
2639 | public override void AssignVarSlot(TokenDeclVar declVar, XMRInstArSizes arSizes) | ||
2640 | { | ||
2641 | declVar.vTableArray = iarArraysFieldInfo; | ||
2642 | declVar.vTableIndex = arSizes.iasArrays++; | ||
2643 | } | ||
2644 | } | ||
2645 | public class TokenTypeBool: TokenType | ||
2646 | { | ||
2647 | public TokenTypeBool(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { } | ||
2648 | public TokenTypeBool(Token original) : base(original) { } | ||
2649 | public override Type ToSysType() | ||
2650 | { | ||
2651 | return typeof(bool); | ||
2652 | } | ||
2653 | public override string ToString() | ||
2654 | { | ||
2655 | return "bool"; | ||
2656 | } | ||
2657 | } | ||
2658 | public class TokenTypeChar: TokenType | ||
2659 | { | ||
2660 | private static readonly FieldInfo iarCharsFieldInfo = typeof(XMRInstArrays).GetField("iarChars"); | ||
2661 | |||
2662 | public TokenTypeChar(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { } | ||
2663 | public TokenTypeChar(Token original) : base(original) { } | ||
2664 | public override Type ToSysType() | ||
2665 | { | ||
2666 | return typeof(char); | ||
2667 | } | ||
2668 | public override string ToString() | ||
2669 | { | ||
2670 | return "char"; | ||
2671 | } | ||
2672 | public override void AssignVarSlot(TokenDeclVar declVar, XMRInstArSizes arSizes) | ||
2673 | { | ||
2674 | declVar.vTableArray = iarCharsFieldInfo; | ||
2675 | declVar.vTableIndex = arSizes.iasChars++; | ||
2676 | } | ||
2677 | } | ||
2678 | public class TokenTypeExc: TokenType | ||
2679 | { | ||
2680 | private static readonly FieldInfo iarObjectsFieldInfo = typeof(XMRInstArrays).GetField("iarObjects"); | ||
2681 | |||
2682 | public TokenTypeExc(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { } | ||
2683 | public TokenTypeExc(Token original) : base(original) { } | ||
2684 | public override Type ToSysType() | ||
2685 | { | ||
2686 | return typeof(Exception); | ||
2687 | } | ||
2688 | public override string ToString() | ||
2689 | { | ||
2690 | return "exception"; | ||
2691 | } | ||
2692 | public override void AssignVarSlot(TokenDeclVar declVar, XMRInstArSizes arSizes) | ||
2693 | { | ||
2694 | declVar.vTableArray = iarObjectsFieldInfo; | ||
2695 | declVar.vTableIndex = arSizes.iasObjects++; | ||
2696 | } | ||
2697 | } | ||
2698 | public class TokenTypeFloat: TokenType | ||
2699 | { | ||
2700 | private static readonly FieldInfo iarFloatsFieldInfo = typeof(XMRInstArrays).GetField("iarFloats"); | ||
2701 | |||
2702 | public TokenTypeFloat(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { } | ||
2703 | public TokenTypeFloat(Token original) : base(original) { } | ||
2704 | public override Type ToSysType() | ||
2705 | { | ||
2706 | return typeof(double); | ||
2707 | } | ||
2708 | public override string ToString() | ||
2709 | { | ||
2710 | return "float"; | ||
2711 | } | ||
2712 | public override void AssignVarSlot(TokenDeclVar declVar, XMRInstArSizes arSizes) | ||
2713 | { | ||
2714 | declVar.vTableArray = iarFloatsFieldInfo; | ||
2715 | declVar.vTableIndex = arSizes.iasFloats++; | ||
2716 | } | ||
2717 | } | ||
2718 | public class TokenTypeInt: TokenType | ||
2719 | { | ||
2720 | private static readonly FieldInfo iarIntegersFieldInfo = typeof(XMRInstArrays).GetField("iarIntegers"); | ||
2721 | |||
2722 | public TokenTypeInt(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { } | ||
2723 | public TokenTypeInt(Token original) : base(original) { } | ||
2724 | public override Type ToSysType() | ||
2725 | { | ||
2726 | return typeof(int); | ||
2727 | } | ||
2728 | public override string ToString() | ||
2729 | { | ||
2730 | return "integer"; | ||
2731 | } | ||
2732 | public override void AssignVarSlot(TokenDeclVar declVar, XMRInstArSizes arSizes) | ||
2733 | { | ||
2734 | declVar.vTableArray = iarIntegersFieldInfo; | ||
2735 | declVar.vTableIndex = arSizes.iasIntegers++; | ||
2736 | } | ||
2737 | } | ||
2738 | public class TokenTypeKey: TokenType | ||
2739 | { | ||
2740 | private static readonly FieldInfo iarStringsFieldInfo = typeof(XMRInstArrays).GetField("iarStrings"); | ||
2741 | |||
2742 | public TokenTypeKey(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { } | ||
2743 | public TokenTypeKey(Token original) : base(original) { } | ||
2744 | public override Type ToSysType() | ||
2745 | { | ||
2746 | return typeof(string); | ||
2747 | } | ||
2748 | public override string ToString() | ||
2749 | { | ||
2750 | return "key"; | ||
2751 | } | ||
2752 | public override void AssignVarSlot(TokenDeclVar declVar, XMRInstArSizes arSizes) | ||
2753 | { | ||
2754 | declVar.vTableArray = iarStringsFieldInfo; | ||
2755 | declVar.vTableIndex = arSizes.iasStrings++; | ||
2756 | } | ||
2757 | } | ||
2758 | public class TokenTypeList: TokenType | ||
2759 | { | ||
2760 | private static readonly FieldInfo iarListsFieldInfo = typeof(XMRInstArrays).GetField("iarLists"); | ||
2761 | private static readonly ConstructorInfo htListCtor = typeof(HeapTrackerList).GetConstructor(new Type[] { typeof(XMRInstAbstract) }); | ||
2762 | |||
2763 | public TokenTypeList(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { } | ||
2764 | public TokenTypeList(Token original) : base(original) { } | ||
2765 | public override Type ToSysType() | ||
2766 | { | ||
2767 | return typeof(LSL_List); | ||
2768 | } | ||
2769 | public override string ToString() | ||
2770 | { | ||
2771 | return "list"; | ||
2772 | } | ||
2773 | public override void AssignVarSlot(TokenDeclVar declVar, XMRInstArSizes arSizes) | ||
2774 | { | ||
2775 | declVar.vTableArray = iarListsFieldInfo; | ||
2776 | declVar.vTableIndex = arSizes.iasLists++; | ||
2777 | } | ||
2778 | public override Type ToHeapTrackerType() | ||
2779 | { | ||
2780 | return typeof(HeapTrackerList); | ||
2781 | } | ||
2782 | public override ConstructorInfo GetHeapTrackerCtor() | ||
2783 | { | ||
2784 | return htListCtor; | ||
2785 | } | ||
2786 | public override void CallHeapTrackerPopMeth(Token errorAt, ScriptMyILGen ilGen) | ||
2787 | { | ||
2788 | HeapTrackerList.GenPop(errorAt, ilGen); | ||
2789 | } | ||
2790 | public override void CallHeapTrackerPushMeth(Token errorAt, ScriptMyILGen ilGen) | ||
2791 | { | ||
2792 | HeapTrackerList.GenPush(errorAt, ilGen); | ||
2793 | } | ||
2794 | } | ||
2795 | public class TokenTypeObject: TokenType | ||
2796 | { | ||
2797 | private static readonly FieldInfo iarObjectsFieldInfo = typeof(XMRInstArrays).GetField("iarObjects"); | ||
2798 | private static readonly ConstructorInfo htObjectCtor = typeof(HeapTrackerObject).GetConstructor(new Type[] { typeof(XMRInstAbstract) }); | ||
2799 | |||
2800 | public TokenTypeObject(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { } | ||
2801 | public TokenTypeObject(Token original) : base(original) { } | ||
2802 | public override Type ToSysType() | ||
2803 | { | ||
2804 | return typeof(object); | ||
2805 | } | ||
2806 | public override string ToString() | ||
2807 | { | ||
2808 | return "object"; | ||
2809 | } | ||
2810 | public override void AssignVarSlot(TokenDeclVar declVar, XMRInstArSizes arSizes) | ||
2811 | { | ||
2812 | declVar.vTableArray = iarObjectsFieldInfo; | ||
2813 | declVar.vTableIndex = arSizes.iasObjects++; | ||
2814 | } | ||
2815 | public override Type ToHeapTrackerType() | ||
2816 | { | ||
2817 | return typeof(HeapTrackerObject); | ||
2818 | } | ||
2819 | public override ConstructorInfo GetHeapTrackerCtor() | ||
2820 | { | ||
2821 | return htObjectCtor; | ||
2822 | } | ||
2823 | public override void CallHeapTrackerPopMeth(Token errorAt, ScriptMyILGen ilGen) | ||
2824 | { | ||
2825 | HeapTrackerObject.GenPop(errorAt, ilGen); | ||
2826 | } | ||
2827 | public override void CallHeapTrackerPushMeth(Token errorAt, ScriptMyILGen ilGen) | ||
2828 | { | ||
2829 | HeapTrackerObject.GenPush(errorAt, ilGen); | ||
2830 | } | ||
2831 | } | ||
2832 | public class TokenTypeRot: TokenType | ||
2833 | { | ||
2834 | private static readonly FieldInfo iarRotationsFieldInfo = typeof(XMRInstArrays).GetField("iarRotations"); | ||
2835 | |||
2836 | public TokenTypeRot(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { } | ||
2837 | public TokenTypeRot(Token original) : base(original) { } | ||
2838 | public override Type ToSysType() | ||
2839 | { | ||
2840 | return typeof(LSL_Rotation); | ||
2841 | } | ||
2842 | public override string ToString() | ||
2843 | { | ||
2844 | return "rotation"; | ||
2845 | } | ||
2846 | public override void AssignVarSlot(TokenDeclVar declVar, XMRInstArSizes arSizes) | ||
2847 | { | ||
2848 | declVar.vTableArray = iarRotationsFieldInfo; | ||
2849 | declVar.vTableIndex = arSizes.iasRotations++; | ||
2850 | } | ||
2851 | } | ||
2852 | public class TokenTypeStr: TokenType | ||
2853 | { | ||
2854 | private static readonly FieldInfo iarStringsFieldInfo = typeof(XMRInstArrays).GetField("iarStrings"); | ||
2855 | private static readonly ConstructorInfo htStringCtor = typeof(HeapTrackerString).GetConstructor(new Type[] { typeof(XMRInstAbstract) }); | ||
2856 | |||
2857 | public TokenTypeStr(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { } | ||
2858 | public TokenTypeStr(Token original) : base(original) { } | ||
2859 | public override Type ToSysType() | ||
2860 | { | ||
2861 | return typeof(string); | ||
2862 | } | ||
2863 | public override string ToString() | ||
2864 | { | ||
2865 | return "string"; | ||
2866 | } | ||
2867 | public override void AssignVarSlot(TokenDeclVar declVar, XMRInstArSizes arSizes) | ||
2868 | { | ||
2869 | declVar.vTableArray = iarStringsFieldInfo; | ||
2870 | declVar.vTableIndex = arSizes.iasStrings++; | ||
2871 | } | ||
2872 | public override Type ToHeapTrackerType() | ||
2873 | { | ||
2874 | return typeof(HeapTrackerString); | ||
2875 | } | ||
2876 | public override ConstructorInfo GetHeapTrackerCtor() | ||
2877 | { | ||
2878 | return htStringCtor; | ||
2879 | } | ||
2880 | public override void CallHeapTrackerPopMeth(Token errorAt, ScriptMyILGen ilGen) | ||
2881 | { | ||
2882 | HeapTrackerString.GenPop(errorAt, ilGen); | ||
2883 | } | ||
2884 | public override void CallHeapTrackerPushMeth(Token errorAt, ScriptMyILGen ilGen) | ||
2885 | { | ||
2886 | HeapTrackerString.GenPush(errorAt, ilGen); | ||
2887 | } | ||
2888 | } | ||
2889 | public class TokenTypeUndef: TokenType | ||
2890 | { // for the 'undef' constant, ie, null object pointer | ||
2891 | public TokenTypeUndef(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { } | ||
2892 | public TokenTypeUndef(Token original) : base(original) { } | ||
2893 | public override Type ToSysType() | ||
2894 | { | ||
2895 | return typeof(object); | ||
2896 | } | ||
2897 | public override string ToString() | ||
2898 | { | ||
2899 | return "undef"; | ||
2900 | } | ||
2901 | } | ||
2902 | public class TokenTypeVec: TokenType | ||
2903 | { | ||
2904 | private static readonly FieldInfo iarVectorsFieldInfo = typeof(XMRInstArrays).GetField("iarVectors"); | ||
2905 | |||
2906 | public TokenTypeVec(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { } | ||
2907 | public TokenTypeVec(Token original) : base(original) { } | ||
2908 | public override Type ToSysType() | ||
2909 | { | ||
2910 | return typeof(LSL_Vector); | ||
2911 | } | ||
2912 | public override string ToString() | ||
2913 | { | ||
2914 | return "vector"; | ||
2915 | } | ||
2916 | public override void AssignVarSlot(TokenDeclVar declVar, XMRInstArSizes arSizes) | ||
2917 | { | ||
2918 | declVar.vTableArray = iarVectorsFieldInfo; | ||
2919 | declVar.vTableIndex = arSizes.iasVectors++; | ||
2920 | } | ||
2921 | } | ||
2922 | public class TokenTypeVoid: TokenType | ||
2923 | { // used only for function/method return types | ||
2924 | public TokenTypeVoid(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { } | ||
2925 | public TokenTypeVoid(Token original) : base(original) { } | ||
2926 | public override Type ToSysType() | ||
2927 | { | ||
2928 | return typeof(void); | ||
2929 | } | ||
2930 | public override string ToString() | ||
2931 | { | ||
2932 | return "void"; | ||
2933 | } | ||
2934 | } | ||
2935 | |||
2936 | public class TokenTypeLSLFloat: TokenTypeFloat | ||
2937 | { | ||
2938 | public TokenTypeLSLFloat(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { } | ||
2939 | public TokenTypeLSLFloat(Token original) : base(original) { } | ||
2940 | public override Type ToLSLWrapType() | ||
2941 | { | ||
2942 | return typeof(LSL_Float); | ||
2943 | } | ||
2944 | } | ||
2945 | public class TokenTypeLSLInt: TokenTypeInt | ||
2946 | { | ||
2947 | public TokenTypeLSLInt(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { } | ||
2948 | public TokenTypeLSLInt(Token original) : base(original) { } | ||
2949 | public override Type ToLSLWrapType() | ||
2950 | { | ||
2951 | return typeof(LSL_Integer); | ||
2952 | } | ||
2953 | } | ||
2954 | public class TokenTypeLSLKey: TokenTypeKey | ||
2955 | { | ||
2956 | public TokenTypeLSLKey(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { } | ||
2957 | public TokenTypeLSLKey(Token original) : base(original) { } | ||
2958 | public override Type ToLSLWrapType() | ||
2959 | { | ||
2960 | return typeof(LSL_Key); | ||
2961 | } | ||
2962 | } | ||
2963 | public class TokenTypeLSLString: TokenTypeStr | ||
2964 | { | ||
2965 | public TokenTypeLSLString(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { } | ||
2966 | public TokenTypeLSLString(Token original) : base(original) { } | ||
2967 | public override Type ToLSLWrapType() | ||
2968 | { | ||
2969 | return typeof(LSL_String); | ||
2970 | } | ||
2971 | } | ||
2972 | } | ||