CMDscan.cpp 78 KB

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