CMDscan.cpp 66 KB

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