CMDscan.cpp 66 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558
  1. #define yy_create_buffer CMD_create_buffer
  2. #define yy_delete_buffer CMD_delete_buffer
  3. #define yy_scan_buffer CMD_scan_buffer
  4. #define yy_scan_string CMD_scan_string
  5. #define yy_scan_bytes CMD_scan_bytes
  6. #define yy_flex_debug CMD_flex_debug
  7. #define yy_init_buffer CMD_init_buffer
  8. #define yy_flush_buffer CMD_flush_buffer
  9. #define yy_load_buffer_state CMD_load_buffer_state
  10. #define yy_switch_to_buffer CMD_switch_to_buffer
  11. #define yyin CMDin
  12. #define yyleng CMDleng
  13. #define yylex CMDlex
  14. #define yyout CMDout
  15. #define yyrestart CMDrestart
  16. #define yytext CMDtext
  17. #define yywrap CMDwrap
  18. #line 20 "CMDscan.cpp"
  19. /* A lexical scanner generated by flex */
  20. /* Scanner skeleton version:
  21. * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.85 95/04/24 10:48:47 vern Exp $
  22. */
  23. #define FLEX_SCANNER
  24. #define YY_FLEX_MAJOR_VERSION 2
  25. #define YY_FLEX_MINOR_VERSION 5
  26. #include <stdio.h>
  27. /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
  28. #ifdef c_plusplus
  29. #ifndef __cplusplus
  30. #define __cplusplus
  31. #endif
  32. #endif
  33. #ifdef __cplusplus
  34. #include <stdlib.h>
  35. //nclude <unistd.h>
  36. /* Use prototypes in function declarations. */
  37. #define YY_USE_PROTOS
  38. /* The "const" storage-class-modifier is valid. */
  39. #define YY_USE_CONST
  40. #else /* ! __cplusplus */
  41. #if __STDC__
  42. #define YY_USE_PROTOS
  43. #define YY_USE_CONST
  44. #endif /* __STDC__ */
  45. #endif /* ! __cplusplus */
  46. #ifdef __TURBOC__
  47. #pragma warn -rch
  48. #pragma warn -use
  49. #include <io.h>
  50. #include <stdlib.h>
  51. #define YY_USE_CONST
  52. #define YY_USE_PROTOS
  53. #endif
  54. #ifdef YY_USE_CONST
  55. #define yyconst const
  56. #else
  57. #define yyconst
  58. #endif
  59. #ifdef YY_USE_PROTOS
  60. #define YY_PROTO(proto) proto
  61. #else
  62. #define YY_PROTO(proto) ()
  63. #endif
  64. /* Returned upon end-of-file. */
  65. #define YY_NULL 0
  66. /* Promotes a possibly negative, possibly signed char to an unsigned
  67. * integer for use as an array index. If the signed char is negative,
  68. * we want to instead treat it as an 8-bit unsigned char, hence the
  69. * double cast.
  70. */
  71. #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
  72. /* Enter a start condition. This macro really ought to take a parameter,
  73. * but we do it the disgusting crufty way forced on us by the ()-less
  74. * definition of BEGIN.
  75. */
  76. #define BEGIN yy_start = 1 + 2 *
  77. /* Translate the current start state into a value that can be later handed
  78. * to BEGIN to return to the state. The YYSTATE alias is for lex
  79. * compatibility.
  80. */
  81. #define YY_START ((yy_start - 1) / 2)
  82. #define YYSTATE YY_START
  83. /* Action number for EOF rule of a given start state. */
  84. #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
  85. /* Special action meaning "start processing a new file". */
  86. #define YY_NEW_FILE yyrestart( yyin )
  87. #define YY_END_OF_BUFFER_CHAR 0
  88. /* Size of default input buffer. */
  89. #define YY_BUF_SIZE 16384
  90. typedef struct yy_buffer_state *YY_BUFFER_STATE;
  91. extern int yyleng;
  92. extern FILE *yyin, *yyout;
  93. #define EOB_ACT_CONTINUE_SCAN 0
  94. #define EOB_ACT_END_OF_FILE 1
  95. #define EOB_ACT_LAST_MATCH 2
  96. /* The funky do-while in the following #define is used to turn the definition
  97. * int a single C statement (which needs a semi-colon terminator). This
  98. * avoids problems with code like:
  99. *
  100. * if ( condition_holds )
  101. * yyless( 5 );
  102. * else
  103. * do_something_else();
  104. *
  105. * Prior to using the do-while the compiler would get upset at the
  106. * "else" because it interpreted the "if" statement as being all
  107. * done when it reached the ';' after the yyless() call.
  108. */
  109. /* Return all but the first 'n' matched characters back to the input stream. */
  110. #define yyless(n) \
  111. do \
  112. { \
  113. /* Undo effects of setting up yytext. */ \
  114. *yy_cp = yy_hold_char; \
  115. yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
  116. YY_DO_BEFORE_ACTION; /* set up yytext again */ \
  117. } \
  118. while ( 0 )
  119. #define unput(c) yyunput( c, yytext_ptr )
  120. /* The following is because we cannot portably get our hands on size_t
  121. * (without autoconf's help, which isn't available because we want
  122. * flex-generated scanners to compile on their own).
  123. */
  124. typedef unsigned int yy_size_t;
  125. struct yy_buffer_state
  126. {
  127. FILE *yy_input_file;
  128. char *yy_ch_buf; /* input buffer */
  129. char *yy_buf_pos; /* current position in input buffer */
  130. /* Size of input buffer in bytes, not including room for EOB
  131. * characters.
  132. */
  133. yy_size_t yy_buf_size;
  134. /* Number of characters read into yy_ch_buf, not including EOB
  135. * characters.
  136. */
  137. int yy_n_chars;
  138. /* Whether we "own" the buffer - i.e., we know we created it,
  139. * and can realloc() it to grow it, and should free() it to
  140. * delete it.
  141. */
  142. int yy_is_our_buffer;
  143. /* Whether this is an "interactive" input source; if so, and
  144. * if we're using stdio for input, then we want to use getc()
  145. * instead of fread(), to make sure we stop fetching input after
  146. * each newline.
  147. */
  148. int yy_is_interactive;
  149. /* Whether we're considered to be at the beginning of a line.
  150. * If so, '^' rules will be active on the next match, otherwise
  151. * not.
  152. */
  153. int yy_at_bol;
  154. /* Whether to try to fill the input buffer when we reach the
  155. * end of it.
  156. */
  157. int yy_fill_buffer;
  158. int yy_buffer_status;
  159. #define YY_BUFFER_NEW 0
  160. #define YY_BUFFER_NORMAL 1
  161. /* When an EOF's been seen but there's still some text to process
  162. * then we mark the buffer as YY_EOF_PENDING, to indicate that we
  163. * shouldn't try reading from the input source any more. We might
  164. * still have a bunch of tokens to match, though, because of
  165. * possible backing-up.
  166. *
  167. * When we actually see the EOF, we change the status to "new"
  168. * (via yyrestart()), so that the user can continue scanning by
  169. * just pointing yyin at a new input file.
  170. */
  171. #define YY_BUFFER_EOF_PENDING 2
  172. };
  173. static YY_BUFFER_STATE yy_current_buffer = 0;
  174. /* We provide macros for accessing buffer states in case in the
  175. * future we want to put the buffer states in a more general
  176. * "scanner state".
  177. */
  178. #define YY_CURRENT_BUFFER yy_current_buffer
  179. /* yy_hold_char holds the character lost when yytext is formed. */
  180. static char yy_hold_char;
  181. static int yy_n_chars; /* number of characters read into yy_ch_buf */
  182. int yyleng;
  183. /* Points to current character in buffer. */
  184. static char *yy_c_buf_p = (char *) 0;
  185. static int yy_init = 1; /* whether we need to initialize */
  186. static int yy_start = 0; /* start state number */
  187. /* Flag which is used to allow yywrap()'s to do buffer switches
  188. * instead of setting up a fresh yyin. A bit of a hack ...
  189. */
  190. static int yy_did_buffer_switch_on_eof;
  191. void yyrestart YY_PROTO(( FILE *input_file ));
  192. void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
  193. void yy_load_buffer_state YY_PROTO(( void ));
  194. YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
  195. void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
  196. void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
  197. void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
  198. #define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
  199. YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
  200. YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *str ));
  201. YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
  202. static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
  203. static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
  204. static void yy_flex_free YY_PROTO(( void * ));
  205. #define yy_new_buffer yy_create_buffer
  206. #define yy_set_interactive(is_interactive) \
  207. { \
  208. if ( ! yy_current_buffer ) \
  209. yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
  210. yy_current_buffer->yy_is_interactive = is_interactive; \
  211. }
  212. #define yy_set_bol(at_bol) \
  213. { \
  214. if ( ! yy_current_buffer ) \
  215. yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
  216. yy_current_buffer->yy_at_bol = at_bol; \
  217. }
  218. #define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
  219. typedef unsigned char YY_CHAR;
  220. FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
  221. typedef int yy_state_type;
  222. extern char *yytext;
  223. #define yytext_ptr yytext
  224. static yy_state_type yy_get_previous_state YY_PROTO(( void ));
  225. static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
  226. static int yy_get_next_buffer YY_PROTO(( void ));
  227. static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
  228. /* Done after the current pattern has been matched and before the
  229. * corresponding action - sets up yytext.
  230. */
  231. #define YY_DO_BEFORE_ACTION \
  232. yytext_ptr = yy_bp; \
  233. yyleng = (int) (yy_cp - yy_bp); \
  234. yy_hold_char = *yy_cp; \
  235. *yy_cp = '\0'; \
  236. yy_c_buf_p = yy_cp;
  237. #define YY_NUM_RULES 94
  238. #define YY_END_OF_BUFFER 95
  239. static yyconst short int yy_accept[224] =
  240. { 0,
  241. 0, 0, 95, 93, 1, 5, 4, 51, 93, 93,
  242. 58, 57, 93, 41, 42, 45, 43, 56, 44, 50,
  243. 46, 90, 90, 52, 53, 47, 61, 48, 38, 36,
  244. 88, 88, 88, 88, 39, 40, 59, 88, 88, 88,
  245. 88, 88, 88, 88, 88, 88, 88, 88, 88, 88,
  246. 88, 54, 49, 55, 60, 1, 0, 9, 0, 6,
  247. 0, 0, 17, 87, 25, 12, 26, 0, 7, 0,
  248. 23, 16, 21, 15, 22, 31, 91, 37, 3, 24,
  249. 0, 90, 0, 0, 14, 19, 11, 8, 10, 20,
  250. 88, 33, 88, 88, 27, 88, 88, 88, 88, 88,
  251. 88, 69, 88, 88, 88, 88, 70, 62, 88, 88,
  252. 63, 88, 88, 88, 88, 88, 88, 28, 13, 18,
  253. 92, 87, 0, 32, 3, 3, 91, 0, 91, 89,
  254. 29, 30, 35, 34, 88, 88, 88, 88, 88, 88,
  255. 88, 88, 73, 88, 88, 76, 88, 88, 88, 88,
  256. 88, 88, 92, 0, 3, 2, 88, 88, 79, 88,
  257. 88, 88, 66, 88, 88, 88, 88, 88, 88, 88,
  258. 88, 85, 88, 3, 0, 88, 64, 88, 88, 88,
  259. 86, 88, 88, 88, 88, 88, 88, 88, 68, 0,
  260. 67, 88, 88, 88, 88, 88, 88, 88, 65, 88,
  261. 81, 0, 88, 88, 82, 72, 88, 88, 83, 88,
  262. 80, 0, 74, 88, 71, 75, 88, 88, 0, 78,
  263. 84, 77, 0
  264. } ;
  265. static yyconst int yy_ec[256] =
  266. { 0,
  267. 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
  268. 2, 2, 4, 1, 1, 1, 1, 1, 1, 1,
  269. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  270. 1, 2, 5, 6, 1, 7, 8, 9, 10, 11,
  271. 12, 13, 14, 15, 16, 17, 18, 19, 20, 20,
  272. 20, 20, 20, 20, 20, 20, 20, 21, 22, 23,
  273. 24, 25, 26, 27, 28, 29, 30, 31, 32, 31,
  274. 33, 33, 33, 33, 33, 34, 33, 35, 33, 36,
  275. 33, 33, 37, 38, 33, 33, 33, 39, 33, 33,
  276. 40, 41, 42, 43, 33, 1, 44, 45, 46, 47,
  277. 48, 49, 50, 51, 52, 33, 53, 54, 55, 56,
  278. 57, 58, 33, 59, 60, 61, 62, 33, 63, 39,
  279. 33, 33, 64, 65, 66, 67, 1, 1, 1, 1,
  280. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  281. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  282. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  283. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  284. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  285. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  286. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  287. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  288. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  289. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  290. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  291. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  292. 1, 1, 1, 1, 1
  293. } ;
  294. static yyconst int yy_meta[68] =
  295. { 0,
  296. 1, 1, 2, 2, 1, 1, 1, 1, 1, 1,
  297. 1, 1, 1, 1, 1, 1, 1, 3, 4, 4,
  298. 5, 1, 1, 6, 1, 1, 1, 4, 4, 4,
  299. 4, 4, 7, 7, 7, 7, 7, 7, 7, 1,
  300. 1, 1, 1, 4, 4, 4, 4, 4, 4, 7,
  301. 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
  302. 7, 7, 7, 1, 1, 1, 1
  303. } ;
  304. static yyconst short int yy_base[237] =
  305. { 0,
  306. 0, 0, 337, 338, 334, 338, 338, 61, 63, 51,
  307. 53, 65, 66, 338, 338, 311, 64, 338, 66, 60,
  308. 68, 76, 80, 313, 338, 60, 309, 77, 338, 338,
  309. 0, 298, 295, 302, 338, 338, 305, 268, 268, 54,
  310. 61, 272, 59, 38, 62, 266, 280, 275, 62, 263,
  311. 270, 338, 89, 338, 338, 318, 295, 338, 111, 338,
  312. 314, 100, 338, 296, 338, 338, 338, 112, 338, 312,
  313. 338, 338, 338, 290, 338, 338, 107, 338, 296, 338,
  314. 110, 114, 121, 0, 338, 289, 338, 338, 338, 288,
  315. 0, 0, 281, 281, 338, 249, 260, 247, 250, 244,
  316. 255, 0, 243, 248, 242, 244, 0, 0, 244, 235,
  317. 0, 251, 235, 239, 242, 231, 240, 338, 338, 338,
  318. 270, 269, 268, 338, 0, 139, 119, 125, 128, 0,
  319. 338, 338, 0, 0, 240, 243, 238, 224, 240, 239,
  320. 234, 221, 232, 233, 230, 0, 224, 214, 225, 213,
  321. 225, 218, 250, 249, 146, 152, 210, 215, 0, 215,
  322. 221, 203, 0, 216, 219, 201, 201, 216, 200, 204,
  323. 211, 0, 208, 155, 237, 193, 0, 197, 198, 197,
  324. 0, 204, 197, 190, 197, 190, 197, 193, 0, 225,
  325. 0, 180, 184, 179, 177, 153, 158, 151, 0, 134,
  326. 187, 157, 143, 144, 0, 176, 123, 126, 0, 112,
  327. 338, 160, 0, 115, 338, 0, 88, 76, 162, 0,
  328. 0, 0, 338, 170, 174, 181, 185, 189, 193, 200,
  329. 119, 204, 211, 218, 225, 232
  330. } ;
  331. static yyconst short int yy_def[237] =
  332. { 0,
  333. 223, 1, 223, 223, 223, 223, 223, 223, 224, 225,
  334. 225, 223, 226, 223, 223, 223, 223, 223, 223, 223,
  335. 223, 223, 223, 223, 223, 223, 223, 223, 223, 223,
  336. 227, 227, 227, 227, 223, 223, 223, 227, 227, 227,
  337. 227, 227, 227, 227, 227, 227, 227, 227, 227, 227,
  338. 227, 223, 223, 223, 223, 223, 223, 223, 224, 223,
  339. 224, 228, 223, 229, 223, 223, 223, 226, 223, 226,
  340. 223, 223, 223, 223, 223, 223, 223, 223, 230, 223,
  341. 223, 223, 223, 231, 223, 223, 223, 223, 223, 223,
  342. 227, 227, 227, 227, 223, 227, 227, 227, 227, 227,
  343. 227, 227, 227, 227, 227, 227, 227, 227, 227, 227,
  344. 227, 227, 227, 227, 227, 227, 227, 223, 223, 223,
  345. 232, 229, 229, 223, 230, 233, 223, 223, 223, 231,
  346. 223, 223, 227, 227, 227, 227, 227, 227, 227, 227,
  347. 227, 227, 227, 227, 227, 227, 227, 227, 227, 227,
  348. 227, 227, 232, 232, 234, 223, 227, 227, 227, 227,
  349. 227, 227, 227, 227, 227, 227, 227, 227, 227, 227,
  350. 227, 227, 227, 234, 223, 227, 227, 227, 227, 227,
  351. 227, 227, 227, 227, 227, 227, 227, 227, 227, 223,
  352. 227, 227, 227, 227, 227, 227, 227, 227, 227, 227,
  353. 227, 235, 227, 227, 227, 227, 227, 227, 227, 227,
  354. 223, 236, 227, 227, 223, 227, 227, 227, 236, 227,
  355. 227, 227, 0, 223, 223, 223, 223, 223, 223, 223,
  356. 223, 223, 223, 223, 223, 223
  357. } ;
  358. static yyconst short int yy_nxt[406] =
  359. { 0,
  360. 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
  361. 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
  362. 24, 25, 26, 27, 28, 29, 30, 31, 31, 31,
  363. 31, 31, 31, 31, 32, 31, 33, 34, 31, 35,
  364. 4, 36, 37, 38, 39, 40, 41, 42, 43, 31,
  365. 31, 44, 31, 31, 31, 45, 46, 47, 48, 49,
  366. 50, 31, 51, 52, 53, 54, 55, 57, 60, 62,
  367. 62, 62, 62, 66, 63, 69, 65, 72, 77, 77,
  368. 78, 74, 86, 87, 58, 79, 107, 73, 67, 75,
  369. 76, 80, 81, 108, 82, 82, 81, 98, 82, 82,
  370. 89, 90, 104, 61, 100, 109, 70, 83, 101, 110,
  371. 99, 83, 118, 114, 84, 105, 60, 102, 62, 62,
  372. 106, 69, 130, 83, 115, 77, 77, 83, 127, 127,
  373. 81, 222, 82, 82, 128, 221, 128, 127, 127, 129,
  374. 129, 156, 156, 129, 129, 83, 129, 129, 156, 156,
  375. 83, 61, 70, 119, 156, 156, 125, 156, 156, 156,
  376. 156, 83, 156, 156, 156, 156, 83, 220, 218, 175,
  377. 59, 217, 59, 59, 59, 59, 59, 64, 216, 64,
  378. 64, 68, 215, 68, 68, 68, 68, 68, 91, 214,
  379. 213, 91, 121, 211, 210, 121, 122, 122, 209, 122,
  380. 125, 208, 125, 125, 125, 125, 125, 153, 153, 207,
  381. 153, 155, 155, 155, 155, 155, 155, 155, 174, 174,
  382. 174, 174, 174, 174, 174, 212, 212, 206, 212, 212,
  383. 212, 212, 219, 219, 219, 219, 219, 219, 219, 205,
  384. 204, 203, 202, 201, 200, 199, 198, 197, 196, 195,
  385. 194, 193, 192, 191, 190, 189, 188, 187, 186, 185,
  386. 184, 183, 182, 181, 180, 179, 178, 177, 176, 154,
  387. 154, 173, 172, 171, 170, 169, 168, 167, 166, 165,
  388. 164, 163, 162, 161, 160, 159, 158, 157, 123, 123,
  389. 154, 152, 151, 150, 149, 148, 147, 146, 145, 144,
  390. 143, 142, 141, 140, 139, 138, 137, 136, 135, 134,
  391. 133, 132, 131, 126, 124, 68, 123, 59, 120, 56,
  392. 117, 116, 113, 112, 111, 103, 97, 96, 95, 94,
  393. 93, 92, 88, 85, 71, 56, 223, 3, 223, 223,
  394. 223, 223, 223, 223, 223, 223, 223, 223, 223, 223,
  395. 223, 223, 223, 223, 223, 223, 223, 223, 223, 223,
  396. 223, 223, 223, 223, 223, 223, 223, 223, 223, 223,
  397. 223, 223, 223, 223, 223, 223, 223, 223, 223, 223,
  398. 223, 223, 223, 223, 223, 223, 223, 223, 223, 223,
  399. 223, 223, 223, 223, 223, 223, 223, 223, 223, 223,
  400. 223, 223, 223, 223, 223
  401. } ;
  402. static yyconst short int yy_chk[406] =
  403. { 0,
  404. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  405. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  406. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  407. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  408. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  409. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  410. 1, 1, 1, 1, 1, 1, 1, 8, 9, 10,
  411. 10, 11, 11, 12, 10, 13, 11, 17, 20, 20,
  412. 21, 19, 26, 26, 8, 21, 44, 17, 12, 19,
  413. 19, 21, 22, 44, 22, 22, 23, 40, 23, 23,
  414. 28, 28, 43, 9, 41, 45, 13, 22, 41, 45,
  415. 40, 23, 53, 49, 22, 43, 59, 41, 62, 62,
  416. 43, 68, 231, 22, 49, 77, 77, 23, 81, 81,
  417. 82, 218, 82, 82, 83, 217, 83, 127, 127, 83,
  418. 83, 126, 126, 128, 128, 82, 129, 129, 155, 155,
  419. 127, 59, 68, 53, 156, 156, 126, 174, 174, 202,
  420. 202, 82, 212, 212, 219, 219, 127, 214, 210, 156,
  421. 224, 208, 224, 224, 224, 224, 224, 225, 207, 225,
  422. 225, 226, 206, 226, 226, 226, 226, 226, 227, 204,
  423. 203, 227, 228, 201, 200, 228, 229, 229, 198, 229,
  424. 230, 197, 230, 230, 230, 230, 230, 232, 232, 196,
  425. 232, 233, 233, 233, 233, 233, 233, 233, 234, 234,
  426. 234, 234, 234, 234, 234, 235, 235, 195, 235, 235,
  427. 235, 235, 236, 236, 236, 236, 236, 236, 236, 194,
  428. 193, 192, 190, 188, 187, 186, 185, 184, 183, 182,
  429. 180, 179, 178, 176, 175, 173, 171, 170, 169, 168,
  430. 167, 166, 165, 164, 162, 161, 160, 158, 157, 154,
  431. 153, 152, 151, 150, 149, 148, 147, 145, 144, 143,
  432. 142, 141, 140, 139, 138, 137, 136, 135, 123, 122,
  433. 121, 117, 116, 115, 114, 113, 112, 110, 109, 106,
  434. 105, 104, 103, 101, 100, 99, 98, 97, 96, 94,
  435. 93, 90, 86, 79, 74, 70, 64, 61, 57, 56,
  436. 51, 50, 48, 47, 46, 42, 39, 38, 37, 34,
  437. 33, 32, 27, 24, 16, 5, 3, 223, 223, 223,
  438. 223, 223, 223, 223, 223, 223, 223, 223, 223, 223,
  439. 223, 223, 223, 223, 223, 223, 223, 223, 223, 223,
  440. 223, 223, 223, 223, 223, 223, 223, 223, 223, 223,
  441. 223, 223, 223, 223, 223, 223, 223, 223, 223, 223,
  442. 223, 223, 223, 223, 223, 223, 223, 223, 223, 223,
  443. 223, 223, 223, 223, 223, 223, 223, 223, 223, 223,
  444. 223, 223, 223, 223, 223
  445. } ;
  446. static yy_state_type yy_last_accepting_state;
  447. static char *yy_last_accepting_cpos;
  448. /* The intent behind this definition is that it'll catch
  449. * any uses of REJECT which flex missed.
  450. */
  451. #define REJECT reject_used_but_not_detected
  452. #define yymore() yymore_used_but_not_detected
  453. #define YY_MORE_ADJ 0
  454. char *yytext;
  455. #line 1 "CMDscan.l"
  456. #define INITIAL 0
  457. #line 2 "CMDscan.l"
  458. // flex --nounput -o CMDscan.cpp -P CMD CMDscan.l
  459. #define YYLMAX 4096
  460. #define YY_NO_UNISTD_H
  461. #include <stdio.h>
  462. #include "platform/platform.h"
  463. #include "core/stringTable.h"
  464. #include "console/console.h"
  465. #include "console/compiler.h"
  466. #include "console/dynamicTypes.h"
  467. #include "core/strings/stringFunctions.h"
  468. template< typename T >
  469. struct Token
  470. {
  471. T value;
  472. S32 lineNumber;
  473. };
  474. // Can't have ctors in structs used in unions, so we have this.
  475. template< typename T >
  476. inline Token< T > MakeToken( T value, U32 lineNumber )
  477. {
  478. Token< T > result;
  479. result.value = value;
  480. result.lineNumber = lineNumber;
  481. return result;
  482. }
  483. #include "console/cmdgram.h"
  484. // HACK: C++17 and beyond can't use register keyword
  485. #define register
  486. using namespace Compiler;
  487. #define YY_NEVER_INTERACTIVE 1
  488. // Some basic parsing primitives...
  489. static int Sc_ScanDocBlock();
  490. static int Sc_ScanString(int ret);
  491. static int Sc_ScanNum();
  492. static int Sc_ScanVar();
  493. static int Sc_ScanHex();
  494. static int Sc_ScanIdent();
  495. // Deal with debuggability of FLEX.
  496. #ifdef TORQUE_DEBUG
  497. #define FLEX_DEBUG 1
  498. #else
  499. #define FLEX_DEBUG 0
  500. #endif
  501. // Install our own input code...
  502. #undef CMDgetc
  503. int CMDgetc();
  504. // Hack to make windows lex happy.
  505. #ifndef isatty
  506. inline int isatty(int) { return 0; }
  507. #endif
  508. // Wrap our getc, so that lex doesn't try to do its own buffering/file IO.
  509. #define YY_INPUT(buf,result,max_size) \
  510. { \
  511. int c = '*', n; \
  512. for ( n = 0; n < max_size && \
  513. (c = CMDgetc()) != EOF && c != '\n'; ++n ) \
  514. buf[n] = (char) c; \
  515. if ( c == '\n' ) \
  516. buf[n++] = (char) c; \
  517. result = n; \
  518. }
  519. // General helper stuff.
  520. static int lineIndex;
  521. // File state
  522. void CMDSetScanBuffer(const char *sb, const char *fn);
  523. const char * CMDgetFileLine(int &lineNumber);
  524. // Error reporting
  525. void CMDerror(const char * s, ...);
  526. // Reset the parser.
  527. void CMDrestart(FILE *in);
  528. #line 638 "CMDscan.cpp"
  529. /* Macros after this point can all be overridden by user definitions in
  530. * section 1.
  531. */
  532. #ifndef YY_SKIP_YYWRAP
  533. #ifdef __cplusplus
  534. extern "C" int yywrap YY_PROTO(( void ));
  535. #else
  536. extern int yywrap YY_PROTO(( void ));
  537. #endif
  538. #endif
  539. #ifndef YY_NO_UNPUT
  540. static void yyunput YY_PROTO(( int c, char *buf_ptr ));
  541. #endif
  542. #ifndef yytext_ptr
  543. static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
  544. #endif
  545. #ifndef YY_NO_INPUT
  546. #ifdef __cplusplus
  547. static int yyinput YY_PROTO(( void ));
  548. #else
  549. static int input YY_PROTO(( void ));
  550. #endif
  551. #endif
  552. #if YY_STACK_USED
  553. static int yy_start_stack_ptr = 0;
  554. static int yy_start_stack_depth = 0;
  555. static int *yy_start_stack = 0;
  556. #ifndef YY_NO_PUSH_STATE
  557. static void yy_push_state YY_PROTO(( int new_state ));
  558. #endif
  559. #ifndef YY_NO_POP_STATE
  560. static void yy_pop_state YY_PROTO(( void ));
  561. #endif
  562. #ifndef YY_NO_TOP_STATE
  563. static int yy_top_state YY_PROTO(( void ));
  564. #endif
  565. #else
  566. #define YY_NO_PUSH_STATE 1
  567. #define YY_NO_POP_STATE 1
  568. #define YY_NO_TOP_STATE 1
  569. #endif
  570. #ifdef YY_MALLOC_DECL
  571. YY_MALLOC_DECL
  572. #else
  573. #if __STDC__
  574. #ifndef __cplusplus
  575. #include <stdlib.h>
  576. #endif
  577. #else
  578. /* Just try to get by without declaring the routines. This will fail
  579. * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
  580. * or sizeof(void*) != sizeof(int).
  581. */
  582. #endif
  583. #endif
  584. /* Amount of stuff to slurp up with each read. */
  585. #ifndef YY_READ_BUF_SIZE
  586. #define YY_READ_BUF_SIZE 8192
  587. #endif
  588. /* Copy whatever the last rule matched to the standard output. */
  589. #ifndef ECHO
  590. /* This used to be an fputs(), but since the string might contain NUL's,
  591. * we now use fwrite().
  592. */
  593. #define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
  594. #endif
  595. /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
  596. * is returned in "result".
  597. */
  598. #ifndef YY_INPUT
  599. #define YY_INPUT(buf,result,max_size) \
  600. if ( yy_current_buffer->yy_is_interactive ) \
  601. { \
  602. int c = '*', n; \
  603. for ( n = 0; n < max_size && \
  604. (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
  605. buf[n] = (char) c; \
  606. if ( c == '\n' ) \
  607. buf[n++] = (char) c; \
  608. if ( c == EOF && ferror( yyin ) ) \
  609. YY_FATAL_ERROR( "input in flex scanner failed" ); \
  610. result = n; \
  611. } \
  612. else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
  613. && ferror( yyin ) ) \
  614. YY_FATAL_ERROR( "input in flex scanner failed" );
  615. #endif
  616. /* No semi-colon after return; correct usage is to write "yyterminate();" -
  617. * we don't want an extra ';' after the "return" because that will cause
  618. * some compilers to complain about unreachable statements.
  619. */
  620. #ifndef yyterminate
  621. #define yyterminate() return YY_NULL
  622. #endif
  623. /* Number of entries by which start-condition stack grows. */
  624. #ifndef YY_START_STACK_INCR
  625. #define YY_START_STACK_INCR 25
  626. #endif
  627. /* Report a fatal error. */
  628. #ifndef YY_FATAL_ERROR
  629. #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
  630. #endif
  631. /* Default declaration of generated scanner - a define so the user can
  632. * easily add parameters.
  633. */
  634. #ifndef YY_DECL
  635. #define YY_DECL int yylex YY_PROTO(( void ))
  636. #endif
  637. /* Code executed at the beginning of each rule, after yytext and yyleng
  638. * have been set up.
  639. */
  640. #ifndef YY_USER_ACTION
  641. #define YY_USER_ACTION
  642. #endif
  643. /* Code executed at the end of each rule. */
  644. #ifndef YY_BREAK
  645. #define YY_BREAK break;
  646. #endif
  647. #define YY_RULE_SETUP \
  648. YY_USER_ACTION
  649. YY_DECL
  650. {
  651. register yy_state_type yy_current_state;
  652. register char *yy_cp, *yy_bp;
  653. register int yy_act;
  654. #line 108 "CMDscan.l"
  655. ;
  656. #line 788 "CMDscan.cpp"
  657. if ( yy_init )
  658. {
  659. yy_init = 0;
  660. #ifdef YY_USER_INIT
  661. YY_USER_INIT;
  662. #endif
  663. if ( ! yy_start )
  664. yy_start = 1; /* first start state */
  665. if ( ! yyin )
  666. yyin = stdin;
  667. if ( ! yyout )
  668. yyout = stdout;
  669. if ( ! yy_current_buffer )
  670. yy_current_buffer =
  671. yy_create_buffer( yyin, YY_BUF_SIZE );
  672. yy_load_buffer_state();
  673. }
  674. while ( 1 ) /* loops until end-of-file is reached */
  675. {
  676. yy_cp = yy_c_buf_p;
  677. /* Support of yytext. */
  678. *yy_cp = yy_hold_char;
  679. /* yy_bp points to the position in yy_ch_buf of the start of
  680. * the current run.
  681. */
  682. yy_bp = yy_cp;
  683. yy_current_state = yy_start;
  684. yy_match:
  685. do
  686. {
  687. register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
  688. if ( yy_accept[yy_current_state] )
  689. {
  690. yy_last_accepting_state = yy_current_state;
  691. yy_last_accepting_cpos = yy_cp;
  692. }
  693. while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  694. {
  695. yy_current_state = (int) yy_def[yy_current_state];
  696. if ( yy_current_state >= 224 )
  697. yy_c = yy_meta[(unsigned int) yy_c];
  698. }
  699. yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
  700. ++yy_cp;
  701. }
  702. while ( yy_base[yy_current_state] != 338 );
  703. yy_find_action:
  704. yy_act = yy_accept[yy_current_state];
  705. if ( yy_act == 0 )
  706. { /* have to back up */
  707. yy_cp = yy_last_accepting_cpos;
  708. yy_current_state = yy_last_accepting_state;
  709. yy_act = yy_accept[yy_current_state];
  710. }
  711. YY_DO_BEFORE_ACTION;
  712. do_action: /* This label is used only to access EOF actions. */
  713. switch ( yy_act )
  714. { /* beginning of action switch */
  715. case 0: /* must back up */
  716. /* undo the effects of YY_DO_BEFORE_ACTION */
  717. *yy_cp = yy_hold_char;
  718. yy_cp = yy_last_accepting_cpos;
  719. yy_current_state = yy_last_accepting_state;
  720. goto yy_find_action;
  721. case 1:
  722. YY_RULE_SETUP
  723. #line 110 "CMDscan.l"
  724. { }
  725. YY_BREAK
  726. case 2:
  727. YY_RULE_SETUP
  728. #line 111 "CMDscan.l"
  729. { return(Sc_ScanDocBlock()); }
  730. YY_BREAK
  731. case 3:
  732. YY_RULE_SETUP
  733. #line 112 "CMDscan.l"
  734. ;
  735. YY_BREAK
  736. case 4:
  737. YY_RULE_SETUP
  738. #line 113 "CMDscan.l"
  739. ;
  740. YY_BREAK
  741. case 5:
  742. YY_RULE_SETUP
  743. #line 114 "CMDscan.l"
  744. {lineIndex++;}
  745. YY_BREAK
  746. case 6:
  747. YY_RULE_SETUP
  748. #line 115 "CMDscan.l"
  749. { return(Sc_ScanString(STRATOM)); }
  750. YY_BREAK
  751. case 7:
  752. YY_RULE_SETUP
  753. #line 116 "CMDscan.l"
  754. { return(Sc_ScanString(TAGATOM)); }
  755. YY_BREAK
  756. case 8:
  757. YY_RULE_SETUP
  758. #line 117 "CMDscan.l"
  759. { CMDlval.i = MakeToken< int >( opEQ, lineIndex ); return opEQ; }
  760. YY_BREAK
  761. case 9:
  762. YY_RULE_SETUP
  763. #line 118 "CMDscan.l"
  764. { CMDlval.i = MakeToken< int >( opNE, lineIndex ); return opNE; }
  765. YY_BREAK
  766. case 10:
  767. YY_RULE_SETUP
  768. #line 119 "CMDscan.l"
  769. { CMDlval.i = MakeToken< int >( opGE, lineIndex ); return opGE; }
  770. YY_BREAK
  771. case 11:
  772. YY_RULE_SETUP
  773. #line 120 "CMDscan.l"
  774. { CMDlval.i = MakeToken< int >( opLE, lineIndex ); return opLE; }
  775. YY_BREAK
  776. case 12:
  777. YY_RULE_SETUP
  778. #line 121 "CMDscan.l"
  779. { CMDlval.i = MakeToken< int >( opAND, lineIndex ); return opAND; }
  780. YY_BREAK
  781. case 13:
  782. YY_RULE_SETUP
  783. #line 122 "CMDscan.l"
  784. { CMDlval.i = MakeToken< int >( opOR, lineIndex ); return opOR; }
  785. YY_BREAK
  786. case 14:
  787. YY_RULE_SETUP
  788. #line 123 "CMDscan.l"
  789. { CMDlval.i = MakeToken< int >( opCOLONCOLON, lineIndex ); return opCOLONCOLON; }
  790. YY_BREAK
  791. case 15:
  792. YY_RULE_SETUP
  793. #line 124 "CMDscan.l"
  794. { CMDlval.i = MakeToken< int >( opMINUSMINUS, lineIndex ); return opMINUSMINUS; }
  795. YY_BREAK
  796. case 16:
  797. YY_RULE_SETUP
  798. #line 125 "CMDscan.l"
  799. { CMDlval.i = MakeToken< int >( opPLUSPLUS, lineIndex ); return opPLUSPLUS; }
  800. YY_BREAK
  801. case 17:
  802. YY_RULE_SETUP
  803. #line 126 "CMDscan.l"
  804. { CMDlval.i = MakeToken< int >( opSTREQ, lineIndex ); return opSTREQ; }
  805. YY_BREAK
  806. case 18:
  807. YY_RULE_SETUP
  808. #line 127 "CMDscan.l"
  809. { CMDlval.i = MakeToken< int >( opSTRNE, lineIndex ); return opSTRNE; }
  810. YY_BREAK
  811. case 19:
  812. YY_RULE_SETUP
  813. #line 128 "CMDscan.l"
  814. { CMDlval.i = MakeToken< int >( opSHL, lineIndex ); return opSHL; }
  815. YY_BREAK
  816. case 20:
  817. YY_RULE_SETUP
  818. #line 129 "CMDscan.l"
  819. { CMDlval.i = MakeToken< int >( opSHR, lineIndex ); return opSHR; }
  820. YY_BREAK
  821. case 21:
  822. YY_RULE_SETUP
  823. #line 130 "CMDscan.l"
  824. { CMDlval.i = MakeToken< int >( opPLASN, lineIndex ); return opPLASN; }
  825. YY_BREAK
  826. case 22:
  827. YY_RULE_SETUP
  828. #line 131 "CMDscan.l"
  829. { CMDlval.i = MakeToken< int >( opMIASN, lineIndex ); return opMIASN; }
  830. YY_BREAK
  831. case 23:
  832. YY_RULE_SETUP
  833. #line 132 "CMDscan.l"
  834. { CMDlval.i = MakeToken< int >( opMLASN, lineIndex ); return opMLASN; }
  835. YY_BREAK
  836. case 24:
  837. YY_RULE_SETUP
  838. #line 133 "CMDscan.l"
  839. { CMDlval.i = MakeToken< int >( opDVASN, lineIndex ); return opDVASN; }
  840. YY_BREAK
  841. case 25:
  842. YY_RULE_SETUP
  843. #line 134 "CMDscan.l"
  844. { CMDlval.i = MakeToken< int >( opMODASN, lineIndex ); return opMODASN; }
  845. YY_BREAK
  846. case 26:
  847. YY_RULE_SETUP
  848. #line 135 "CMDscan.l"
  849. { CMDlval.i = MakeToken< int >( opANDASN, lineIndex ); return opANDASN; }
  850. YY_BREAK
  851. case 27:
  852. YY_RULE_SETUP
  853. #line 136 "CMDscan.l"
  854. { CMDlval.i = MakeToken< int >( opXORASN, lineIndex ); return opXORASN; }
  855. YY_BREAK
  856. case 28:
  857. YY_RULE_SETUP
  858. #line 137 "CMDscan.l"
  859. { CMDlval.i = MakeToken< int >( opORASN, lineIndex ); return opORASN; }
  860. YY_BREAK
  861. case 29:
  862. YY_RULE_SETUP
  863. #line 138 "CMDscan.l"
  864. { CMDlval.i = MakeToken< int >( opSLASN, lineIndex ); return opSLASN; }
  865. YY_BREAK
  866. case 30:
  867. YY_RULE_SETUP
  868. #line 139 "CMDscan.l"
  869. { CMDlval.i = MakeToken< int >( opSRASN, lineIndex ); return opSRASN; }
  870. YY_BREAK
  871. case 31:
  872. YY_RULE_SETUP
  873. #line 140 "CMDscan.l"
  874. { CMDlval.i = MakeToken< int >( opINTNAME, lineIndex ); return opINTNAME; }
  875. YY_BREAK
  876. case 32:
  877. YY_RULE_SETUP
  878. #line 141 "CMDscan.l"
  879. { CMDlval.i = MakeToken< int >( opINTNAMER, lineIndex ); return opINTNAMER; }
  880. YY_BREAK
  881. case 33:
  882. YY_RULE_SETUP
  883. #line 142 "CMDscan.l"
  884. { CMDlval.i = MakeToken< int >( '\n', lineIndex ); return '@'; }
  885. YY_BREAK
  886. case 34:
  887. YY_RULE_SETUP
  888. #line 143 "CMDscan.l"
  889. { CMDlval.i = MakeToken< int >( '\t', lineIndex ); return '@'; }
  890. YY_BREAK
  891. case 35:
  892. YY_RULE_SETUP
  893. #line 144 "CMDscan.l"
  894. { CMDlval.i = MakeToken< int >( ' ', lineIndex ); return '@'; }
  895. YY_BREAK
  896. case 36:
  897. YY_RULE_SETUP
  898. #line 145 "CMDscan.l"
  899. { CMDlval.i = MakeToken< int >( 0, lineIndex ); return '@'; }
  900. YY_BREAK
  901. case 37:
  902. YY_RULE_SETUP
  903. #line 146 "CMDscan.l"
  904. { /* this comment stops syntax highlighting from getting messed up when editing the lexer in TextPad */
  905. int c = 0, l;
  906. for ( ; ; )
  907. {
  908. l = c;
  909. c = yyinput();
  910. // Is this an open comment?
  911. if ( c == EOF )
  912. {
  913. CMDerror( "unexpected end of file found in comment" );
  914. break;
  915. }
  916. // Increment line numbers.
  917. else if ( c == '\n' )
  918. lineIndex++;
  919. // Did we find the end of the comment?
  920. else if ( l == '*' && c == '/' )
  921. break;
  922. }
  923. }
  924. YY_BREAK
  925. case 38:
  926. #line 170 "CMDscan.l"
  927. case 39:
  928. #line 171 "CMDscan.l"
  929. case 40:
  930. #line 172 "CMDscan.l"
  931. case 41:
  932. #line 173 "CMDscan.l"
  933. case 42:
  934. #line 174 "CMDscan.l"
  935. case 43:
  936. #line 175 "CMDscan.l"
  937. case 44:
  938. #line 176 "CMDscan.l"
  939. case 45:
  940. #line 177 "CMDscan.l"
  941. case 46:
  942. #line 178 "CMDscan.l"
  943. case 47:
  944. #line 179 "CMDscan.l"
  945. case 48:
  946. #line 180 "CMDscan.l"
  947. case 49:
  948. #line 181 "CMDscan.l"
  949. case 50:
  950. #line 182 "CMDscan.l"
  951. case 51:
  952. #line 183 "CMDscan.l"
  953. case 52:
  954. #line 184 "CMDscan.l"
  955. case 53:
  956. #line 185 "CMDscan.l"
  957. case 54:
  958. #line 186 "CMDscan.l"
  959. case 55:
  960. #line 187 "CMDscan.l"
  961. case 56:
  962. #line 188 "CMDscan.l"
  963. case 57:
  964. #line 189 "CMDscan.l"
  965. case 58:
  966. #line 190 "CMDscan.l"
  967. case 59:
  968. #line 191 "CMDscan.l"
  969. case 60:
  970. #line 192 "CMDscan.l"
  971. case 61:
  972. YY_RULE_SETUP
  973. #line 192 "CMDscan.l"
  974. { CMDlval.i = MakeToken< int >( CMDtext[ 0 ], lineIndex ); return CMDtext[ 0 ]; }
  975. YY_BREAK
  976. case 62:
  977. YY_RULE_SETUP
  978. #line 193 "CMDscan.l"
  979. { CMDlval.i = MakeToken< int >( rwIN, lineIndex ); return(rwIN); }
  980. YY_BREAK
  981. case 63:
  982. YY_RULE_SETUP
  983. #line 194 "CMDscan.l"
  984. { CMDlval.i = MakeToken< int >( rwCASEOR, lineIndex ); return(rwCASEOR); }
  985. YY_BREAK
  986. case 64:
  987. YY_RULE_SETUP
  988. #line 195 "CMDscan.l"
  989. { CMDlval.i = MakeToken< int >( rwBREAK, lineIndex ); return(rwBREAK); }
  990. YY_BREAK
  991. case 65:
  992. YY_RULE_SETUP
  993. #line 196 "CMDscan.l"
  994. { CMDlval.i = MakeToken< int >( rwRETURN, lineIndex ); return(rwRETURN); }
  995. YY_BREAK
  996. case 66:
  997. YY_RULE_SETUP
  998. #line 197 "CMDscan.l"
  999. { CMDlval.i = MakeToken< int >( rwELSE, lineIndex ); return(rwELSE); }
  1000. YY_BREAK
  1001. case 67:
  1002. YY_RULE_SETUP
  1003. #line 198 "CMDscan.l"
  1004. { CMDlval.i = MakeToken< int >( rwASSERT, lineIndex ); return(rwASSERT); }
  1005. YY_BREAK
  1006. case 68:
  1007. YY_RULE_SETUP
  1008. #line 199 "CMDscan.l"
  1009. { CMDlval.i = MakeToken< int >( rwWHILE, lineIndex ); return(rwWHILE); }
  1010. YY_BREAK
  1011. case 69:
  1012. YY_RULE_SETUP
  1013. #line 200 "CMDscan.l"
  1014. { CMDlval.i = MakeToken< int >( rwDO, lineIndex ); return(rwDO); }
  1015. YY_BREAK
  1016. case 70:
  1017. YY_RULE_SETUP
  1018. #line 201 "CMDscan.l"
  1019. { CMDlval.i = MakeToken< int >( rwIF, lineIndex ); return(rwIF); }
  1020. YY_BREAK
  1021. case 71:
  1022. YY_RULE_SETUP
  1023. #line 202 "CMDscan.l"
  1024. { CMDlval.i = MakeToken< int >( rwFOREACHSTR, lineIndex ); return(rwFOREACHSTR); }
  1025. YY_BREAK
  1026. case 72:
  1027. YY_RULE_SETUP
  1028. #line 203 "CMDscan.l"
  1029. { CMDlval.i = MakeToken< int >( rwFOREACH, lineIndex ); return(rwFOREACH); }
  1030. YY_BREAK
  1031. case 73:
  1032. YY_RULE_SETUP
  1033. #line 204 "CMDscan.l"
  1034. { CMDlval.i = MakeToken< int >( rwFOR, lineIndex ); return(rwFOR); }
  1035. YY_BREAK
  1036. case 74:
  1037. YY_RULE_SETUP
  1038. #line 205 "CMDscan.l"
  1039. { CMDlval.i = MakeToken< int >( rwCONTINUE, lineIndex ); return(rwCONTINUE); }
  1040. YY_BREAK
  1041. case 75:
  1042. YY_RULE_SETUP
  1043. #line 206 "CMDscan.l"
  1044. { CMDlval.i = MakeToken< int >( rwDEFINE, lineIndex ); return(rwDEFINE); }
  1045. YY_BREAK
  1046. case 76:
  1047. YY_RULE_SETUP
  1048. #line 207 "CMDscan.l"
  1049. { CMDlval.i = MakeToken< int >( rwDECLARE, lineIndex ); return(rwDECLARE); }
  1050. YY_BREAK
  1051. case 77:
  1052. YY_RULE_SETUP
  1053. #line 208 "CMDscan.l"
  1054. { CMDlval.i = MakeToken< int >( rwDECLARESINGLETON, lineIndex ); return(rwDECLARESINGLETON); }
  1055. YY_BREAK
  1056. case 78:
  1057. YY_RULE_SETUP
  1058. #line 209 "CMDscan.l"
  1059. { CMDlval.i = MakeToken< int >( rwDATABLOCK, lineIndex ); return(rwDATABLOCK); }
  1060. YY_BREAK
  1061. case 79:
  1062. YY_RULE_SETUP
  1063. #line 210 "CMDscan.l"
  1064. { CMDlval.i = MakeToken< int >( rwCASE, lineIndex ); return(rwCASE); }
  1065. YY_BREAK
  1066. case 80:
  1067. YY_RULE_SETUP
  1068. #line 211 "CMDscan.l"
  1069. { CMDlval.i = MakeToken< int >( rwSWITCHSTR, lineIndex ); return(rwSWITCHSTR); }
  1070. YY_BREAK
  1071. case 81:
  1072. YY_RULE_SETUP
  1073. #line 212 "CMDscan.l"
  1074. { CMDlval.i = MakeToken< int >( rwSWITCH, lineIndex ); return(rwSWITCH); }
  1075. YY_BREAK
  1076. case 82:
  1077. YY_RULE_SETUP
  1078. #line 213 "CMDscan.l"
  1079. { CMDlval.i = MakeToken< int >( rwDEFAULT, lineIndex ); return(rwDEFAULT); }
  1080. YY_BREAK
  1081. case 83:
  1082. YY_RULE_SETUP
  1083. #line 214 "CMDscan.l"
  1084. { CMDlval.i = MakeToken< int >( rwPACKAGE, lineIndex ); return(rwPACKAGE); }
  1085. YY_BREAK
  1086. case 84:
  1087. YY_RULE_SETUP
  1088. #line 215 "CMDscan.l"
  1089. { CMDlval.i = MakeToken< int >( rwNAMESPACE, lineIndex ); return(rwNAMESPACE); }
  1090. YY_BREAK
  1091. case 85:
  1092. YY_RULE_SETUP
  1093. #line 216 "CMDscan.l"
  1094. { CMDlval.i = MakeToken< int >( 1, lineIndex ); return INTCONST; }
  1095. YY_BREAK
  1096. case 86:
  1097. YY_RULE_SETUP
  1098. #line 217 "CMDscan.l"
  1099. { CMDlval.i = MakeToken< int >( 0, lineIndex ); return INTCONST; }
  1100. YY_BREAK
  1101. case 87:
  1102. YY_RULE_SETUP
  1103. #line 218 "CMDscan.l"
  1104. { return(Sc_ScanVar()); }
  1105. YY_BREAK
  1106. case 88:
  1107. YY_RULE_SETUP
  1108. #line 220 "CMDscan.l"
  1109. { return Sc_ScanIdent(); }
  1110. YY_BREAK
  1111. case 89:
  1112. YY_RULE_SETUP
  1113. #line 221 "CMDscan.l"
  1114. return(Sc_ScanHex());
  1115. YY_BREAK
  1116. case 90:
  1117. YY_RULE_SETUP
  1118. #line 222 "CMDscan.l"
  1119. { CMDtext[CMDleng] = 0; CMDlval.i = MakeToken< int >( dAtoi(CMDtext), lineIndex ); return INTCONST; }
  1120. YY_BREAK
  1121. case 91:
  1122. YY_RULE_SETUP
  1123. #line 223 "CMDscan.l"
  1124. return Sc_ScanNum();
  1125. YY_BREAK
  1126. case 92:
  1127. YY_RULE_SETUP
  1128. #line 224 "CMDscan.l"
  1129. return(ILLEGAL_TOKEN);
  1130. YY_BREAK
  1131. case 93:
  1132. YY_RULE_SETUP
  1133. #line 225 "CMDscan.l"
  1134. return(ILLEGAL_TOKEN);
  1135. YY_BREAK
  1136. case 94:
  1137. YY_RULE_SETUP
  1138. #line 226 "CMDscan.l"
  1139. ECHO;
  1140. YY_BREAK
  1141. #line 1294 "CMDscan.cpp"
  1142. case YY_STATE_EOF(INITIAL):
  1143. yyterminate();
  1144. case YY_END_OF_BUFFER:
  1145. {
  1146. /* Amount of text matched not including the EOB char. */
  1147. int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
  1148. /* Undo the effects of YY_DO_BEFORE_ACTION. */
  1149. *yy_cp = yy_hold_char;
  1150. if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
  1151. {
  1152. /* We're scanning a new file or input source. It's
  1153. * possible that this happened because the user
  1154. * just pointed yyin at a new source and called
  1155. * yylex(). If so, then we have to assure
  1156. * consistency between yy_current_buffer and our
  1157. * globals. Here is the right place to do so, because
  1158. * this is the first action (other than possibly a
  1159. * back-up) that will match for the new input source.
  1160. */
  1161. yy_n_chars = yy_current_buffer->yy_n_chars;
  1162. yy_current_buffer->yy_input_file = yyin;
  1163. yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
  1164. }
  1165. /* Note that here we test for yy_c_buf_p "<=" to the position
  1166. * of the first EOB in the buffer, since yy_c_buf_p will
  1167. * already have been incremented past the NUL character
  1168. * (since all states make transitions on EOB to the
  1169. * end-of-buffer state). Contrast this with the test
  1170. * in input().
  1171. */
  1172. if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
  1173. { /* This was really a NUL. */
  1174. yy_state_type yy_next_state;
  1175. yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
  1176. yy_current_state = yy_get_previous_state();
  1177. /* Okay, we're now positioned to make the NUL
  1178. * transition. We couldn't have
  1179. * yy_get_previous_state() go ahead and do it
  1180. * for us because it doesn't know how to deal
  1181. * with the possibility of jamming (and we don't
  1182. * want to build jamming into it because then it
  1183. * will run more slowly).
  1184. */
  1185. yy_next_state = yy_try_NUL_trans( yy_current_state );
  1186. yy_bp = yytext_ptr + YY_MORE_ADJ;
  1187. if ( yy_next_state )
  1188. {
  1189. /* Consume the NUL. */
  1190. yy_cp = ++yy_c_buf_p;
  1191. yy_current_state = yy_next_state;
  1192. goto yy_match;
  1193. }
  1194. else
  1195. {
  1196. yy_cp = yy_c_buf_p;
  1197. goto yy_find_action;
  1198. }
  1199. }
  1200. else switch ( yy_get_next_buffer() )
  1201. {
  1202. case EOB_ACT_END_OF_FILE:
  1203. {
  1204. yy_did_buffer_switch_on_eof = 0;
  1205. if ( yywrap() )
  1206. {
  1207. /* Note: because we've taken care in
  1208. * yy_get_next_buffer() to have set up
  1209. * yytext, we can now set up
  1210. * yy_c_buf_p so that if some total
  1211. * hoser (like flex itself) wants to
  1212. * call the scanner after we return the
  1213. * YY_NULL, it'll still work - another
  1214. * YY_NULL will get returned.
  1215. */
  1216. yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
  1217. yy_act = YY_STATE_EOF(YY_START);
  1218. goto do_action;
  1219. }
  1220. else
  1221. {
  1222. if ( ! yy_did_buffer_switch_on_eof )
  1223. YY_NEW_FILE;
  1224. }
  1225. break;
  1226. }
  1227. case EOB_ACT_CONTINUE_SCAN:
  1228. yy_c_buf_p =
  1229. yytext_ptr + yy_amount_of_matched_text;
  1230. yy_current_state = yy_get_previous_state();
  1231. yy_cp = yy_c_buf_p;
  1232. yy_bp = yytext_ptr + YY_MORE_ADJ;
  1233. goto yy_match;
  1234. case EOB_ACT_LAST_MATCH:
  1235. yy_c_buf_p =
  1236. &yy_current_buffer->yy_ch_buf[yy_n_chars];
  1237. yy_current_state = yy_get_previous_state();
  1238. yy_cp = yy_c_buf_p;
  1239. yy_bp = yytext_ptr + YY_MORE_ADJ;
  1240. goto yy_find_action;
  1241. }
  1242. break;
  1243. }
  1244. default:
  1245. YY_FATAL_ERROR(
  1246. "fatal flex scanner internal error--no action found" );
  1247. } /* end of action switch */
  1248. } /* end of scanning one token */
  1249. } /* end of yylex */
  1250. /* yy_get_next_buffer - try to read in a new buffer
  1251. *
  1252. * Returns a code representing an action:
  1253. * EOB_ACT_LAST_MATCH -
  1254. * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
  1255. * EOB_ACT_END_OF_FILE - end of file
  1256. */
  1257. static int yy_get_next_buffer()
  1258. {
  1259. register char *dest = yy_current_buffer->yy_ch_buf;
  1260. register char *source = yytext_ptr;
  1261. register int number_to_move, i;
  1262. int ret_val;
  1263. if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
  1264. YY_FATAL_ERROR(
  1265. "fatal flex scanner internal error--end of buffer missed" );
  1266. if ( yy_current_buffer->yy_fill_buffer == 0 )
  1267. { /* Don't try to fill the buffer, so this is an EOF. */
  1268. if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
  1269. {
  1270. /* We matched a singled characater, the EOB, so
  1271. * treat this as a final EOF.
  1272. */
  1273. return EOB_ACT_END_OF_FILE;
  1274. }
  1275. else
  1276. {
  1277. /* We matched some text prior to the EOB, first
  1278. * process it.
  1279. */
  1280. return EOB_ACT_LAST_MATCH;
  1281. }
  1282. }
  1283. /* Try to read more data. */
  1284. /* First move last chars to start of buffer. */
  1285. number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
  1286. for ( i = 0; i < number_to_move; ++i )
  1287. *(dest++) = *(source++);
  1288. if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
  1289. /* don't do the read, it's not guaranteed to return an EOF,
  1290. * just force an EOF
  1291. */
  1292. yy_n_chars = 0;
  1293. else
  1294. {
  1295. int num_to_read =
  1296. yy_current_buffer->yy_buf_size - number_to_move - 1;
  1297. while ( num_to_read <= 0 )
  1298. { /* Not enough room in the buffer - grow it. */
  1299. #ifdef YY_USES_REJECT
  1300. YY_FATAL_ERROR(
  1301. "input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
  1302. #else
  1303. /* just a shorter name for the current buffer */
  1304. YY_BUFFER_STATE b = yy_current_buffer;
  1305. int yy_c_buf_p_offset =
  1306. (int) (yy_c_buf_p - b->yy_ch_buf);
  1307. if ( b->yy_is_our_buffer )
  1308. {
  1309. int new_size = b->yy_buf_size * 2;
  1310. if ( new_size <= 0 )
  1311. b->yy_buf_size += b->yy_buf_size / 8;
  1312. else
  1313. b->yy_buf_size *= 2;
  1314. b->yy_ch_buf = (char *)
  1315. /* Include room in for 2 EOB chars. */
  1316. yy_flex_realloc( (void *) b->yy_ch_buf,
  1317. b->yy_buf_size + 2 );
  1318. }
  1319. else
  1320. /* Can't grow it, we don't own it. */
  1321. b->yy_ch_buf = 0;
  1322. if ( ! b->yy_ch_buf )
  1323. YY_FATAL_ERROR(
  1324. "fatal error - scanner input buffer overflow" );
  1325. yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
  1326. num_to_read = yy_current_buffer->yy_buf_size -
  1327. number_to_move - 1;
  1328. #endif
  1329. }
  1330. if ( num_to_read > YY_READ_BUF_SIZE )
  1331. num_to_read = YY_READ_BUF_SIZE;
  1332. /* Read in more data. */
  1333. YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
  1334. yy_n_chars, num_to_read );
  1335. }
  1336. if ( yy_n_chars == 0 )
  1337. {
  1338. if ( number_to_move == YY_MORE_ADJ )
  1339. {
  1340. ret_val = EOB_ACT_END_OF_FILE;
  1341. yyrestart( yyin );
  1342. }
  1343. else
  1344. {
  1345. ret_val = EOB_ACT_LAST_MATCH;
  1346. yy_current_buffer->yy_buffer_status =
  1347. YY_BUFFER_EOF_PENDING;
  1348. }
  1349. }
  1350. else
  1351. ret_val = EOB_ACT_CONTINUE_SCAN;
  1352. yy_n_chars += number_to_move;
  1353. yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
  1354. yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
  1355. yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
  1356. return ret_val;
  1357. }
  1358. /* yy_get_previous_state - get the state just before the EOB char was reached */
  1359. static yy_state_type yy_get_previous_state()
  1360. {
  1361. register yy_state_type yy_current_state;
  1362. register char *yy_cp;
  1363. yy_current_state = yy_start;
  1364. for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
  1365. {
  1366. register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
  1367. if ( yy_accept[yy_current_state] )
  1368. {
  1369. yy_last_accepting_state = yy_current_state;
  1370. yy_last_accepting_cpos = yy_cp;
  1371. }
  1372. while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  1373. {
  1374. yy_current_state = (int) yy_def[yy_current_state];
  1375. if ( yy_current_state >= 224 )
  1376. yy_c = yy_meta[(unsigned int) yy_c];
  1377. }
  1378. yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
  1379. }
  1380. return yy_current_state;
  1381. }
  1382. /* yy_try_NUL_trans - try to make a transition on the NUL character
  1383. *
  1384. * synopsis
  1385. * next_state = yy_try_NUL_trans( current_state );
  1386. */
  1387. #ifdef YY_USE_PROTOS
  1388. static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
  1389. #else
  1390. static yy_state_type yy_try_NUL_trans( yy_current_state )
  1391. yy_state_type yy_current_state;
  1392. #endif
  1393. {
  1394. register int yy_is_jam;
  1395. register char *yy_cp = yy_c_buf_p;
  1396. register YY_CHAR yy_c = 1;
  1397. if ( yy_accept[yy_current_state] )
  1398. {
  1399. yy_last_accepting_state = yy_current_state;
  1400. yy_last_accepting_cpos = yy_cp;
  1401. }
  1402. while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  1403. {
  1404. yy_current_state = (int) yy_def[yy_current_state];
  1405. if ( yy_current_state >= 224 )
  1406. yy_c = yy_meta[(unsigned int) yy_c];
  1407. }
  1408. yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
  1409. yy_is_jam = (yy_current_state == 223);
  1410. return yy_is_jam ? 0 : yy_current_state;
  1411. }
  1412. #ifndef YY_NO_UNPUT
  1413. #ifdef YY_USE_PROTOS
  1414. static void yyunput( int c, register char *yy_bp )
  1415. #else
  1416. static void yyunput( c, yy_bp )
  1417. int c;
  1418. register char *yy_bp;
  1419. #endif
  1420. {
  1421. register char *yy_cp = yy_c_buf_p;
  1422. /* undo effects of setting up yytext */
  1423. *yy_cp = yy_hold_char;
  1424. if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
  1425. { /* need to shift things up to make room */
  1426. /* +2 for EOB chars. */
  1427. register int number_to_move = yy_n_chars + 2;
  1428. register char *dest = &yy_current_buffer->yy_ch_buf[
  1429. yy_current_buffer->yy_buf_size + 2];
  1430. register char *source =
  1431. &yy_current_buffer->yy_ch_buf[number_to_move];
  1432. while ( source > yy_current_buffer->yy_ch_buf )
  1433. *--dest = *--source;
  1434. yy_cp += (int) (dest - source);
  1435. yy_bp += (int) (dest - source);
  1436. yy_n_chars = yy_current_buffer->yy_buf_size;
  1437. if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
  1438. YY_FATAL_ERROR( "flex scanner push-back overflow" );
  1439. }
  1440. *--yy_cp = (char) c;
  1441. yytext_ptr = yy_bp;
  1442. yy_hold_char = *yy_cp;
  1443. yy_c_buf_p = yy_cp;
  1444. }
  1445. #endif /* ifndef YY_NO_UNPUT */
  1446. #ifdef __cplusplus
  1447. static int yyinput()
  1448. #else
  1449. static int input()
  1450. #endif
  1451. {
  1452. int c;
  1453. *yy_c_buf_p = yy_hold_char;
  1454. if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
  1455. {
  1456. /* yy_c_buf_p now points to the character we want to return.
  1457. * If this occurs *before* the EOB characters, then it's a
  1458. * valid NUL; if not, then we've hit the end of the buffer.
  1459. */
  1460. if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
  1461. /* This was really a NUL. */
  1462. *yy_c_buf_p = '\0';
  1463. else
  1464. { /* need more input */
  1465. yytext_ptr = yy_c_buf_p;
  1466. ++yy_c_buf_p;
  1467. switch ( yy_get_next_buffer() )
  1468. {
  1469. case EOB_ACT_END_OF_FILE:
  1470. {
  1471. if ( yywrap() )
  1472. {
  1473. yy_c_buf_p =
  1474. yytext_ptr + YY_MORE_ADJ;
  1475. return EOF;
  1476. }
  1477. if ( ! yy_did_buffer_switch_on_eof )
  1478. YY_NEW_FILE;
  1479. #ifdef __cplusplus
  1480. return yyinput();
  1481. #else
  1482. return input();
  1483. #endif
  1484. }
  1485. case EOB_ACT_CONTINUE_SCAN:
  1486. yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
  1487. break;
  1488. case EOB_ACT_LAST_MATCH:
  1489. #ifdef __cplusplus
  1490. YY_FATAL_ERROR(
  1491. "unexpected last match in yyinput()" );
  1492. #else
  1493. YY_FATAL_ERROR(
  1494. "unexpected last match in input()" );
  1495. #endif
  1496. }
  1497. }
  1498. }
  1499. c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */
  1500. *yy_c_buf_p = '\0'; /* preserve yytext */
  1501. yy_hold_char = *++yy_c_buf_p;
  1502. return c;
  1503. }
  1504. #ifdef YY_USE_PROTOS
  1505. void yyrestart( FILE *input_file )
  1506. #else
  1507. void yyrestart( input_file )
  1508. FILE *input_file;
  1509. #endif
  1510. {
  1511. if ( ! yy_current_buffer )
  1512. yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
  1513. yy_init_buffer( yy_current_buffer, input_file );
  1514. yy_load_buffer_state();
  1515. }
  1516. #ifdef YY_USE_PROTOS
  1517. void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
  1518. #else
  1519. void yy_switch_to_buffer( new_buffer )
  1520. YY_BUFFER_STATE new_buffer;
  1521. #endif
  1522. {
  1523. if ( yy_current_buffer == new_buffer )
  1524. return;
  1525. if ( yy_current_buffer )
  1526. {
  1527. /* Flush out information for old buffer. */
  1528. *yy_c_buf_p = yy_hold_char;
  1529. yy_current_buffer->yy_buf_pos = yy_c_buf_p;
  1530. yy_current_buffer->yy_n_chars = yy_n_chars;
  1531. }
  1532. yy_current_buffer = new_buffer;
  1533. yy_load_buffer_state();
  1534. /* We don't actually know whether we did this switch during
  1535. * EOF (yywrap()) processing, but the only time this flag
  1536. * is looked at is after yywrap() is called, so it's safe
  1537. * to go ahead and always set it.
  1538. */
  1539. yy_did_buffer_switch_on_eof = 1;
  1540. }
  1541. #ifdef YY_USE_PROTOS
  1542. void yy_load_buffer_state( void )
  1543. #else
  1544. void yy_load_buffer_state()
  1545. #endif
  1546. {
  1547. yy_n_chars = yy_current_buffer->yy_n_chars;
  1548. yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
  1549. yyin = yy_current_buffer->yy_input_file;
  1550. yy_hold_char = *yy_c_buf_p;
  1551. }
  1552. #ifdef YY_USE_PROTOS
  1553. YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
  1554. #else
  1555. YY_BUFFER_STATE yy_create_buffer( file, size )
  1556. FILE *file;
  1557. int size;
  1558. #endif
  1559. {
  1560. YY_BUFFER_STATE b;
  1561. b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
  1562. if ( ! b )
  1563. YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
  1564. b->yy_buf_size = size;
  1565. /* yy_ch_buf has to be 2 characters longer than the size given because
  1566. * we need to put in 2 end-of-buffer characters.
  1567. */
  1568. b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
  1569. if ( ! b->yy_ch_buf )
  1570. YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
  1571. b->yy_is_our_buffer = 1;
  1572. yy_init_buffer( b, file );
  1573. return b;
  1574. }
  1575. #ifdef YY_USE_PROTOS
  1576. void yy_delete_buffer( YY_BUFFER_STATE b )
  1577. #else
  1578. void yy_delete_buffer( b )
  1579. YY_BUFFER_STATE b;
  1580. #endif
  1581. {
  1582. if ( ! b )
  1583. return;
  1584. if ( b == yy_current_buffer )
  1585. yy_current_buffer = (YY_BUFFER_STATE) 0;
  1586. if ( b->yy_is_our_buffer )
  1587. yy_flex_free( (void *) b->yy_ch_buf );
  1588. yy_flex_free( (void *) b );
  1589. }
  1590. #ifndef YY_ALWAYS_INTERACTIVE
  1591. #ifndef YY_NEVER_INTERACTIVE
  1592. extern int isatty YY_PROTO(( int ));
  1593. #endif
  1594. #endif
  1595. #ifdef YY_USE_PROTOS
  1596. void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
  1597. #else
  1598. void yy_init_buffer( b, file )
  1599. YY_BUFFER_STATE b;
  1600. FILE *file;
  1601. #endif
  1602. {
  1603. yy_flush_buffer( b );
  1604. b->yy_input_file = file;
  1605. b->yy_fill_buffer = 1;
  1606. #if YY_ALWAYS_INTERACTIVE
  1607. b->yy_is_interactive = 1;
  1608. #else
  1609. #if YY_NEVER_INTERACTIVE
  1610. b->yy_is_interactive = 0;
  1611. #else
  1612. b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
  1613. #endif
  1614. #endif
  1615. }
  1616. #ifdef YY_USE_PROTOS
  1617. void yy_flush_buffer( YY_BUFFER_STATE b )
  1618. #else
  1619. void yy_flush_buffer( b )
  1620. YY_BUFFER_STATE b;
  1621. #endif
  1622. {
  1623. b->yy_n_chars = 0;
  1624. /* We always need two end-of-buffer characters. The first causes
  1625. * a transition to the end-of-buffer state. The second causes
  1626. * a jam in that state.
  1627. */
  1628. b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
  1629. b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
  1630. b->yy_buf_pos = &b->yy_ch_buf[0];
  1631. b->yy_at_bol = 1;
  1632. b->yy_buffer_status = YY_BUFFER_NEW;
  1633. if ( b == yy_current_buffer )
  1634. yy_load_buffer_state();
  1635. }
  1636. #ifndef YY_NO_SCAN_BUFFER
  1637. #ifdef YY_USE_PROTOS
  1638. YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
  1639. #else
  1640. YY_BUFFER_STATE yy_scan_buffer( base, size )
  1641. char *base;
  1642. yy_size_t size;
  1643. #endif
  1644. {
  1645. YY_BUFFER_STATE b;
  1646. if ( size < 2 ||
  1647. base[size-2] != YY_END_OF_BUFFER_CHAR ||
  1648. base[size-1] != YY_END_OF_BUFFER_CHAR )
  1649. /* They forgot to leave room for the EOB's. */
  1650. return 0;
  1651. b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
  1652. if ( ! b )
  1653. YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
  1654. b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
  1655. b->yy_buf_pos = b->yy_ch_buf = base;
  1656. b->yy_is_our_buffer = 0;
  1657. b->yy_input_file = 0;
  1658. b->yy_n_chars = b->yy_buf_size;
  1659. b->yy_is_interactive = 0;
  1660. b->yy_at_bol = 1;
  1661. b->yy_fill_buffer = 0;
  1662. b->yy_buffer_status = YY_BUFFER_NEW;
  1663. yy_switch_to_buffer( b );
  1664. return b;
  1665. }
  1666. #endif
  1667. #ifndef YY_NO_SCAN_STRING
  1668. #ifdef YY_USE_PROTOS
  1669. YY_BUFFER_STATE yy_scan_string( yyconst char *str )
  1670. #else
  1671. YY_BUFFER_STATE yy_scan_string( str )
  1672. yyconst char *str;
  1673. #endif
  1674. {
  1675. int len;
  1676. for ( len = 0; str[len]; ++len )
  1677. ;
  1678. return yy_scan_bytes( str, len );
  1679. }
  1680. #endif
  1681. #ifndef YY_NO_SCAN_BYTES
  1682. #ifdef YY_USE_PROTOS
  1683. YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
  1684. #else
  1685. YY_BUFFER_STATE yy_scan_bytes( bytes, len )
  1686. yyconst char *bytes;
  1687. int len;
  1688. #endif
  1689. {
  1690. YY_BUFFER_STATE b;
  1691. char *buf;
  1692. yy_size_t n;
  1693. int i;
  1694. /* Get memory for full buffer, including space for trailing EOB's. */
  1695. n = len + 2;
  1696. buf = (char *) yy_flex_alloc( n );
  1697. if ( ! buf )
  1698. YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
  1699. for ( i = 0; i < len; ++i )
  1700. buf[i] = bytes[i];
  1701. buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
  1702. b = yy_scan_buffer( buf, n );
  1703. if ( ! b )
  1704. YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
  1705. /* It's okay to grow etc. this buffer, and we should throw it
  1706. * away when we're done.
  1707. */
  1708. b->yy_is_our_buffer = 1;
  1709. return b;
  1710. }
  1711. #endif
  1712. #ifndef YY_NO_PUSH_STATE
  1713. #ifdef YY_USE_PROTOS
  1714. static void yy_push_state( int new_state )
  1715. #else
  1716. static void yy_push_state( new_state )
  1717. int new_state;
  1718. #endif
  1719. {
  1720. if ( yy_start_stack_ptr >= yy_start_stack_depth )
  1721. {
  1722. yy_size_t new_size;
  1723. yy_start_stack_depth += YY_START_STACK_INCR;
  1724. new_size = yy_start_stack_depth * sizeof( int );
  1725. if ( ! yy_start_stack )
  1726. yy_start_stack = (int *) yy_flex_alloc( new_size );
  1727. else
  1728. yy_start_stack = (int *) yy_flex_realloc(
  1729. (void *) yy_start_stack, new_size );
  1730. if ( ! yy_start_stack )
  1731. YY_FATAL_ERROR(
  1732. "out of memory expanding start-condition stack" );
  1733. }
  1734. yy_start_stack[yy_start_stack_ptr++] = YY_START;
  1735. BEGIN(new_state);
  1736. }
  1737. #endif
  1738. #ifndef YY_NO_POP_STATE
  1739. static void yy_pop_state()
  1740. {
  1741. if ( --yy_start_stack_ptr < 0 )
  1742. YY_FATAL_ERROR( "start-condition stack underflow" );
  1743. BEGIN(yy_start_stack[yy_start_stack_ptr]);
  1744. }
  1745. #endif
  1746. #ifndef YY_NO_TOP_STATE
  1747. static int yy_top_state()
  1748. {
  1749. return yy_start_stack[yy_start_stack_ptr - 1];
  1750. }
  1751. #endif
  1752. #ifndef YY_EXIT_FAILURE
  1753. #define YY_EXIT_FAILURE 2
  1754. #endif
  1755. #ifdef YY_USE_PROTOS
  1756. static void yy_fatal_error( yyconst char msg[] )
  1757. #else
  1758. static void yy_fatal_error( msg )
  1759. char msg[];
  1760. #endif
  1761. {
  1762. (void) fprintf( stderr, "%s\n", msg );
  1763. exit( YY_EXIT_FAILURE );
  1764. }
  1765. /* Redefine yyless() so it works in section 3 code. */
  1766. #undef yyless
  1767. #define yyless(n) \
  1768. do \
  1769. { \
  1770. /* Undo effects of setting up yytext. */ \
  1771. yytext[yyleng] = yy_hold_char; \
  1772. yy_c_buf_p = yytext + n - YY_MORE_ADJ; \
  1773. yy_hold_char = *yy_c_buf_p; \
  1774. *yy_c_buf_p = '\0'; \
  1775. yyleng = n; \
  1776. } \
  1777. while ( 0 )
  1778. /* Internal utility routines. */
  1779. #ifndef yytext_ptr
  1780. #ifdef YY_USE_PROTOS
  1781. static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
  1782. #else
  1783. static void yy_flex_strncpy( s1, s2, n )
  1784. char *s1;
  1785. yyconst char *s2;
  1786. int n;
  1787. #endif
  1788. {
  1789. register int i;
  1790. for ( i = 0; i < n; ++i )
  1791. s1[i] = s2[i];
  1792. }
  1793. #endif
  1794. #ifdef YY_USE_PROTOS
  1795. static void *yy_flex_alloc( yy_size_t size )
  1796. #else
  1797. static void *yy_flex_alloc( size )
  1798. yy_size_t size;
  1799. #endif
  1800. {
  1801. return (void *) malloc( size );
  1802. }
  1803. #ifdef YY_USE_PROTOS
  1804. static void *yy_flex_realloc( void *ptr, yy_size_t size )
  1805. #else
  1806. static void *yy_flex_realloc( ptr, size )
  1807. void *ptr;
  1808. yy_size_t size;
  1809. #endif
  1810. {
  1811. /* The cast to (char *) in the following accommodates both
  1812. * implementations that use char* generic pointers, and those
  1813. * that use void* generic pointers. It works with the latter
  1814. * because both ANSI C and C++ allow castless assignment from
  1815. * any pointer type to void*, and deal with argument conversions
  1816. * as though doing an assignment.
  1817. */
  1818. return (void *) realloc( (char *) ptr, size );
  1819. }
  1820. #ifdef YY_USE_PROTOS
  1821. static void yy_flex_free( void *ptr )
  1822. #else
  1823. static void yy_flex_free( ptr )
  1824. void *ptr;
  1825. #endif
  1826. {
  1827. free( ptr );
  1828. }
  1829. #if YY_MAIN
  1830. int main()
  1831. {
  1832. yylex();
  1833. return 0;
  1834. }
  1835. #endif
  1836. #line 226 "CMDscan.l"
  1837. static const char *scanBuffer;
  1838. static const char *fileName;
  1839. static int scanIndex;
  1840. const char * CMDGetCurrentFile()
  1841. {
  1842. return fileName;
  1843. }
  1844. int CMDGetCurrentLine()
  1845. {
  1846. return lineIndex;
  1847. }
  1848. extern bool gConsoleSyntaxError;
  1849. void CMDerror(const char *format, ...)
  1850. {
  1851. Compiler::gSyntaxError = true;
  1852. const int BUFMAX = 1024;
  1853. char tempBuf[BUFMAX];
  1854. va_list args;
  1855. va_start( args, format );
  1856. #ifdef TORQUE_OS_WIN
  1857. _vsnprintf( tempBuf, BUFMAX, format, args );
  1858. #else
  1859. vsnprintf( tempBuf, BUFMAX, format, args );
  1860. #endif
  1861. va_end(args);
  1862. if(fileName)
  1863. {
  1864. Con::errorf(ConsoleLogEntry::Script, "%s Line: %d - %s", fileName, lineIndex, tempBuf);
  1865. #ifndef NO_ADVANCED_ERROR_REPORT
  1866. // dhc - lineIndex is bogus. let's try to add some sanity back in.
  1867. int i,j,n;
  1868. char c;
  1869. int linediv = 1;
  1870. // first, walk the buffer, trying to detect line ending type.
  1871. // this is imperfect, if inconsistant line endings exist...
  1872. for (i=0; i<scanIndex; i++)
  1873. {
  1874. c = scanBuffer[i];
  1875. if (c=='\r' && scanBuffer[i+1]=='\n') linediv = 2; // crlf detected
  1876. if (c=='\r' || c=='\n' || c==0) break; // enough for us to stop.
  1877. }
  1878. // grab some of the chars starting at the error location - lineending.
  1879. i = 1; j = 0; n = 1;
  1880. // find prev lineending
  1881. while (n<BUFMAX-8 && i<scanIndex) // cap at file start
  1882. {
  1883. c = scanBuffer[scanIndex-i];
  1884. if ((c=='\r' || c=='\n') && i>BUFMAX>>2) break; // at least get a little data
  1885. n++; i++;
  1886. }
  1887. // find next lineending
  1888. while (n<BUFMAX-8 && j<BUFMAX>>1) // cap at half-buf-size forward
  1889. {
  1890. c = scanBuffer[scanIndex+j];
  1891. if (c==0) break;
  1892. if ((c=='\r' || c=='\n') && j>BUFMAX>>2) break; // at least get a little data
  1893. n++; j++;
  1894. }
  1895. if (i) i--; // chop off extra linefeed.
  1896. if (j) j--; // chop off extra linefeed.
  1897. // build our little text block
  1898. if (i) dStrncpy(tempBuf,scanBuffer+scanIndex-i,i);
  1899. dStrncpy(tempBuf+i,"##", 2); // bracketing.
  1900. tempBuf[i+2] = scanBuffer[scanIndex]; // copy the halt character.
  1901. dStrncpy(tempBuf+i+3,"##", 2); // bracketing.
  1902. if (j) dStrncpy(tempBuf+i+5,scanBuffer+scanIndex+1,j); // +1 to go past current char.
  1903. tempBuf[i+j+5] = 0; // null terminate
  1904. for(n=0; n<i+j+5; n++) // convert CR to LF if alone...
  1905. if (tempBuf[n]=='\r' && tempBuf[n+1]!='\n') tempBuf[n] = '\n';
  1906. // write out to console the advanced error report
  1907. Con::warnf(ConsoleLogEntry::Script, ">>> Advanced script error report. Line %d.", lineIndex);
  1908. Con::warnf(ConsoleLogEntry::Script, ">>> Some error context, with ## on sides of error halt:");
  1909. Con::errorf(ConsoleLogEntry::Script, "%s", tempBuf);
  1910. Con::warnf(ConsoleLogEntry::Script, ">>> Error report complete.\n");
  1911. #endif
  1912. // Update the script-visible error buffer.
  1913. const char *prevStr = Con::getVariable("$ScriptError");
  1914. if (prevStr[0])
  1915. dSprintf(tempBuf, sizeof(tempBuf), "%s\n%s Line: %d - Syntax error.", prevStr, fileName, lineIndex);
  1916. else
  1917. dSprintf(tempBuf, sizeof(tempBuf), "%s Line: %d - Syntax error.", fileName, lineIndex);
  1918. Con::setVariable("$ScriptError", tempBuf);
  1919. // We also need to mark that we came up with a new error.
  1920. static S32 sScriptErrorHash=1000;
  1921. Con::setIntVariable("$ScriptErrorHash", sScriptErrorHash++);
  1922. }
  1923. else
  1924. Con::errorf(ConsoleLogEntry::Script, tempBuf);
  1925. }
  1926. void CMDSetScanBuffer(const char *sb, const char *fn)
  1927. {
  1928. scanBuffer = sb;
  1929. fileName = fn;
  1930. scanIndex = 0;
  1931. lineIndex = 1;
  1932. }
  1933. int CMDgetc()
  1934. {
  1935. int ret = scanBuffer[scanIndex];
  1936. if(ret)
  1937. scanIndex++;
  1938. else
  1939. ret = -1;
  1940. return ret;
  1941. }
  1942. int CMDwrap()
  1943. {
  1944. return 1;
  1945. }
  1946. static int Sc_ScanVar()
  1947. {
  1948. // Truncate the temp buffer...
  1949. CMDtext[CMDleng] = 0;
  1950. // Make it a stringtable string!
  1951. CMDlval.s = MakeToken< StringTableEntry >( StringTable->insert(CMDtext), lineIndex );
  1952. return(VAR);
  1953. }
  1954. static int charConv(int in)
  1955. {
  1956. switch(in)
  1957. {
  1958. case 'r':
  1959. return '\r';
  1960. case 'n':
  1961. return '\n';
  1962. case 't':
  1963. return '\t';
  1964. default:
  1965. return in;
  1966. }
  1967. }
  1968. static int getHexDigit(char c)
  1969. {
  1970. if(c >= '0' && c <= '9')
  1971. return c - '0';
  1972. if(c >= 'A' && c <= 'F')
  1973. return c - 'A' + 10;
  1974. if(c >= 'a' && c <= 'f')
  1975. return c - 'a' + 10;
  1976. return -1;
  1977. }
  1978. static int Sc_ScanDocBlock()
  1979. {
  1980. S32 len = dStrlen(CMDtext);
  1981. char* text = (char *) consoleAlloc(len + 1);
  1982. S32 line = lineIndex;
  1983. for( S32 i = 0, j = 0; j <= len; j++ )
  1984. {
  1985. if( ( j <= (len - 2) ) && ( CMDtext[j] == '/' ) && ( CMDtext[j + 1] == '/' ) && ( CMDtext[j + 2] == '/' ) )
  1986. {
  1987. j += 2;
  1988. continue;
  1989. }
  1990. if( CMDtext[j] == '\r' )
  1991. continue;
  1992. if( CMDtext[j] == '\n' )
  1993. lineIndex++;
  1994. text[i++] = CMDtext[j];
  1995. }
  1996. CMDlval.str = MakeToken< char* >( text, line );
  1997. return(DOCBLOCK);
  1998. }
  1999. static int Sc_ScanString(int ret)
  2000. {
  2001. CMDtext[CMDleng - 1] = 0;
  2002. if(!collapseEscape(CMDtext+1))
  2003. return -1;
  2004. dsize_t bufferLen = dStrlen( CMDtext );
  2005. char* buffer = ( char* ) consoleAlloc( bufferLen );
  2006. dStrcpy( buffer, CMDtext + 1, bufferLen );
  2007. CMDlval.str = MakeToken< char* >( buffer, lineIndex );
  2008. return ret;
  2009. }
  2010. static int Sc_ScanIdent()
  2011. {
  2012. ConsoleBaseType *type;
  2013. CMDtext[CMDleng] = 0;
  2014. if((type = ConsoleBaseType::getTypeByName(CMDtext)) != NULL)
  2015. {
  2016. /* It's a type */
  2017. CMDlval.i = MakeToken< int >( type->getTypeID(), lineIndex );
  2018. return TYPEIDENT;
  2019. }
  2020. /* It's an identifier */
  2021. CMDlval.s = MakeToken< StringTableEntry >( StringTable->insert(CMDtext), lineIndex );
  2022. return IDENT;
  2023. }
  2024. void expandEscape(char *dest, const char *src)
  2025. {
  2026. U8 c;
  2027. while((c = (U8) *src++) != 0)
  2028. {
  2029. if(c == '\"')
  2030. {
  2031. *dest++ = '\\';
  2032. *dest++ = '\"';
  2033. }
  2034. else if(c == '\\')
  2035. {
  2036. *dest++ = '\\';
  2037. *dest++ = '\\';
  2038. }
  2039. else if(c == '\r')
  2040. {
  2041. *dest++ = '\\';
  2042. *dest++ = 'r';
  2043. }
  2044. else if(c == '\n')
  2045. {
  2046. *dest++ = '\\';
  2047. *dest++ = 'n';
  2048. }
  2049. else if(c == '\t')
  2050. {
  2051. *dest++ = '\\';
  2052. *dest++ = 't';
  2053. }
  2054. else if(c == '\'')
  2055. {
  2056. *dest++ = '\\';
  2057. *dest++ = '\'';
  2058. }
  2059. else if((c >= 1 && c <= 7) ||
  2060. (c >= 11 && c <= 12) ||
  2061. (c >= 14 && c <= 15))
  2062. {
  2063. /* Remap around: \b = 0x8, \t = 0x9, \n = 0xa, \r = 0xd */
  2064. static U8 expandRemap[15] = { 0x0,
  2065. 0x0,
  2066. 0x1,
  2067. 0x2,
  2068. 0x3,
  2069. 0x4,
  2070. 0x5,
  2071. 0x6,
  2072. 0x0,
  2073. 0x0,
  2074. 0x0,
  2075. 0x7,
  2076. 0x8,
  2077. 0x0,
  2078. 0x9 };
  2079. *dest++ = '\\';
  2080. *dest++ = 'c';
  2081. if(c == 15)
  2082. *dest++ = 'r';
  2083. else if(c == 16)
  2084. *dest++ = 'p';
  2085. else if(c == 17)
  2086. *dest++ = 'o';
  2087. else
  2088. *dest++ = expandRemap[c] + '0';
  2089. }
  2090. else if(c < 32)
  2091. {
  2092. *dest++ = '\\';
  2093. *dest++ = 'x';
  2094. S32 dig1 = c >> 4;
  2095. S32 dig2 = c & 0xf;
  2096. if(dig1 < 10)
  2097. dig1 += '0';
  2098. else
  2099. dig1 += 'A' - 10;
  2100. if(dig2 < 10)
  2101. dig2 += '0';
  2102. else
  2103. dig2 += 'A' - 10;
  2104. *dest++ = dig1;
  2105. *dest++ = dig2;
  2106. }
  2107. else
  2108. *dest++ = c;
  2109. }
  2110. *dest = '\0';
  2111. }
  2112. bool collapseEscape(char *buf)
  2113. {
  2114. S32 len = dStrlen(buf) + 1;
  2115. for(S32 i = 0; i < len;)
  2116. {
  2117. if(buf[i] == '\\')
  2118. {
  2119. if(buf[i+1] == 'x')
  2120. {
  2121. S32 dig1 = getHexDigit(buf[i+2]);
  2122. if(dig1 == -1)
  2123. return false;
  2124. S32 dig2 = getHexDigit(buf[i+3]);
  2125. if(dig2 == -1)
  2126. return false;
  2127. buf[i] = dig1 * 16 + dig2;
  2128. dMemmove(buf + i + 1, buf + i + 4, len - i - 3);
  2129. len -= 3;
  2130. i++;
  2131. }
  2132. else if(buf[i+1] == 'c')
  2133. {
  2134. /* Remap around: \b = 0x8, \t = 0x9, \n = 0xa, \r = 0xd */
  2135. static U8 collapseRemap[10] = { 0x1,
  2136. 0x2,
  2137. 0x3,
  2138. 0x4,
  2139. 0x5,
  2140. 0x6,
  2141. 0x7,
  2142. 0xb,
  2143. 0xc,
  2144. 0xe };
  2145. if(buf[i+2] == 'r')
  2146. buf[i] = 15;
  2147. else if(buf[i+2] == 'p')
  2148. buf[i] = 16;
  2149. else if(buf[i+2] == 'o')
  2150. buf[i] = 17;
  2151. else
  2152. {
  2153. int dig1 = buf[i+2] - '0';
  2154. if(dig1 < 0 || dig1 > 9)
  2155. return false;
  2156. buf[i] = collapseRemap[dig1];
  2157. }
  2158. // Make sure we don't put 0x1 at the beginning of the string.
  2159. if ((buf[i] == 0x1) && (i == 0))
  2160. {
  2161. buf[i] = 0x2;
  2162. buf[i+1] = 0x1;
  2163. dMemmove(buf + i + 2, buf + i + 3, len - i - 1);
  2164. len -= 1;
  2165. }
  2166. else
  2167. {
  2168. dMemmove(buf + i + 1, buf + i + 3, len - i - 2);
  2169. len -= 2;
  2170. }
  2171. i++;
  2172. }
  2173. else
  2174. {
  2175. buf[i] = charConv(buf[i+1]);
  2176. dMemmove(buf + i + 1, buf + i + 2, len - i - 1);
  2177. len--;
  2178. i++;
  2179. }
  2180. }
  2181. else
  2182. i++;
  2183. }
  2184. return true;
  2185. }
  2186. static int Sc_ScanNum()
  2187. {
  2188. CMDtext[CMDleng] = 0;
  2189. CMDlval.f = MakeToken< double >( dAtof(CMDtext), lineIndex );
  2190. return(FLTCONST);
  2191. }
  2192. static int Sc_ScanHex()
  2193. {
  2194. S32 val = 0;
  2195. dSscanf(CMDtext, "%x", &val);
  2196. CMDlval.i = MakeToken< int >( val, lineIndex );
  2197. return INTCONST;
  2198. }
  2199. void CMD_reset()
  2200. {
  2201. CMDrestart(NULL);
  2202. }