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