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