CMDscan.cc 66 KB

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