CMDscan.cpp 79 KB

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