CMDscan.cpp 66 KB

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