CMDscan.cpp 78 KB

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