CMDscan.cpp 73 KB

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