CMDscan.cpp 68 KB

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