MMRScriptTokenize.cs 122 KB

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