scan-code.c 82 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228
  1. #line 1 "src/scan-code.c"
  2. #line 3 "src/scan-code.c"
  3. #define YY_INT_ALIGNED short int
  4. /* A lexical scanner generated by flex */
  5. /* %not-for-header */
  6. /* %if-c-only */
  7. /* %if-not-reentrant */
  8. #define yy_create_buffer code__create_buffer
  9. #define yy_delete_buffer code__delete_buffer
  10. #define yy_scan_buffer code__scan_buffer
  11. #define yy_scan_string code__scan_string
  12. #define yy_scan_bytes code__scan_bytes
  13. #define yy_init_buffer code__init_buffer
  14. #define yy_flush_buffer code__flush_buffer
  15. #define yy_load_buffer_state code__load_buffer_state
  16. #define yy_switch_to_buffer code__switch_to_buffer
  17. #define yypush_buffer_state code_push_buffer_state
  18. #define yypop_buffer_state code_pop_buffer_state
  19. #define yyensure_buffer_stack code_ensure_buffer_stack
  20. #define yy_flex_debug code__flex_debug
  21. #define yyin code_in
  22. #define yyleng code_leng
  23. #define yylex code_lex
  24. #define yylineno code_lineno
  25. #define yyout code_out
  26. #define yyrestart code_restart
  27. #define yytext code_text
  28. #define yywrap code_wrap
  29. #define yyalloc code_alloc
  30. #define yyrealloc code_realloc
  31. #define yyfree code_free
  32. /* %endif */
  33. /* %endif */
  34. /* %ok-for-header */
  35. #define FLEX_SCANNER
  36. #define YY_FLEX_MAJOR_VERSION 2
  37. #define YY_FLEX_MINOR_VERSION 6
  38. #define YY_FLEX_SUBMINOR_VERSION 4
  39. #if YY_FLEX_SUBMINOR_VERSION > 0
  40. #define FLEX_BETA
  41. #endif
  42. /* %if-c++-only */
  43. /* %endif */
  44. /* %if-c-only */
  45. #ifdef yy_create_buffer
  46. #define code__create_buffer_ALREADY_DEFINED
  47. #else
  48. #define yy_create_buffer code__create_buffer
  49. #endif
  50. #ifdef yy_delete_buffer
  51. #define code__delete_buffer_ALREADY_DEFINED
  52. #else
  53. #define yy_delete_buffer code__delete_buffer
  54. #endif
  55. #ifdef yy_scan_buffer
  56. #define code__scan_buffer_ALREADY_DEFINED
  57. #else
  58. #define yy_scan_buffer code__scan_buffer
  59. #endif
  60. #ifdef yy_scan_string
  61. #define code__scan_string_ALREADY_DEFINED
  62. #else
  63. #define yy_scan_string code__scan_string
  64. #endif
  65. #ifdef yy_scan_bytes
  66. #define code__scan_bytes_ALREADY_DEFINED
  67. #else
  68. #define yy_scan_bytes code__scan_bytes
  69. #endif
  70. #ifdef yy_init_buffer
  71. #define code__init_buffer_ALREADY_DEFINED
  72. #else
  73. #define yy_init_buffer code__init_buffer
  74. #endif
  75. #ifdef yy_flush_buffer
  76. #define code__flush_buffer_ALREADY_DEFINED
  77. #else
  78. #define yy_flush_buffer code__flush_buffer
  79. #endif
  80. #ifdef yy_load_buffer_state
  81. #define code__load_buffer_state_ALREADY_DEFINED
  82. #else
  83. #define yy_load_buffer_state code__load_buffer_state
  84. #endif
  85. #ifdef yy_switch_to_buffer
  86. #define code__switch_to_buffer_ALREADY_DEFINED
  87. #else
  88. #define yy_switch_to_buffer code__switch_to_buffer
  89. #endif
  90. #ifdef yypush_buffer_state
  91. #define code_push_buffer_state_ALREADY_DEFINED
  92. #else
  93. #define yypush_buffer_state code_push_buffer_state
  94. #endif
  95. #ifdef yypop_buffer_state
  96. #define code_pop_buffer_state_ALREADY_DEFINED
  97. #else
  98. #define yypop_buffer_state code_pop_buffer_state
  99. #endif
  100. #ifdef yyensure_buffer_stack
  101. #define code_ensure_buffer_stack_ALREADY_DEFINED
  102. #else
  103. #define yyensure_buffer_stack code_ensure_buffer_stack
  104. #endif
  105. #ifdef yylex
  106. #define code_lex_ALREADY_DEFINED
  107. #else
  108. #define yylex code_lex
  109. #endif
  110. #ifdef yyrestart
  111. #define code_restart_ALREADY_DEFINED
  112. #else
  113. #define yyrestart code_restart
  114. #endif
  115. #ifdef yylex_init
  116. #define code_lex_init_ALREADY_DEFINED
  117. #else
  118. #define yylex_init code_lex_init
  119. #endif
  120. #ifdef yylex_init_extra
  121. #define code_lex_init_extra_ALREADY_DEFINED
  122. #else
  123. #define yylex_init_extra code_lex_init_extra
  124. #endif
  125. #ifdef yylex_destroy
  126. #define code_lex_destroy_ALREADY_DEFINED
  127. #else
  128. #define yylex_destroy code_lex_destroy
  129. #endif
  130. #ifdef yyget_debug
  131. #define code_get_debug_ALREADY_DEFINED
  132. #else
  133. #define yyget_debug code_get_debug
  134. #endif
  135. #ifdef yyset_debug
  136. #define code_set_debug_ALREADY_DEFINED
  137. #else
  138. #define yyset_debug code_set_debug
  139. #endif
  140. #ifdef yyget_extra
  141. #define code_get_extra_ALREADY_DEFINED
  142. #else
  143. #define yyget_extra code_get_extra
  144. #endif
  145. #ifdef yyset_extra
  146. #define code_set_extra_ALREADY_DEFINED
  147. #else
  148. #define yyset_extra code_set_extra
  149. #endif
  150. #ifdef yyget_in
  151. #define code_get_in_ALREADY_DEFINED
  152. #else
  153. #define yyget_in code_get_in
  154. #endif
  155. #ifdef yyset_in
  156. #define code_set_in_ALREADY_DEFINED
  157. #else
  158. #define yyset_in code_set_in
  159. #endif
  160. #ifdef yyget_out
  161. #define code_get_out_ALREADY_DEFINED
  162. #else
  163. #define yyget_out code_get_out
  164. #endif
  165. #ifdef yyset_out
  166. #define code_set_out_ALREADY_DEFINED
  167. #else
  168. #define yyset_out code_set_out
  169. #endif
  170. #ifdef yyget_leng
  171. #define code_get_leng_ALREADY_DEFINED
  172. #else
  173. #define yyget_leng code_get_leng
  174. #endif
  175. #ifdef yyget_text
  176. #define code_get_text_ALREADY_DEFINED
  177. #else
  178. #define yyget_text code_get_text
  179. #endif
  180. #ifdef yyget_lineno
  181. #define code_get_lineno_ALREADY_DEFINED
  182. #else
  183. #define yyget_lineno code_get_lineno
  184. #endif
  185. #ifdef yyset_lineno
  186. #define code_set_lineno_ALREADY_DEFINED
  187. #else
  188. #define yyset_lineno code_set_lineno
  189. #endif
  190. #ifdef yywrap
  191. #define code_wrap_ALREADY_DEFINED
  192. #else
  193. #define yywrap code_wrap
  194. #endif
  195. /* %endif */
  196. #ifdef yyalloc
  197. #define code_alloc_ALREADY_DEFINED
  198. #else
  199. #define yyalloc code_alloc
  200. #endif
  201. #ifdef yyrealloc
  202. #define code_realloc_ALREADY_DEFINED
  203. #else
  204. #define yyrealloc code_realloc
  205. #endif
  206. #ifdef yyfree
  207. #define code_free_ALREADY_DEFINED
  208. #else
  209. #define yyfree code_free
  210. #endif
  211. /* %if-c-only */
  212. #ifdef yytext
  213. #define code_text_ALREADY_DEFINED
  214. #else
  215. #define yytext code_text
  216. #endif
  217. #ifdef yyleng
  218. #define code_leng_ALREADY_DEFINED
  219. #else
  220. #define yyleng code_leng
  221. #endif
  222. #ifdef yyin
  223. #define code_in_ALREADY_DEFINED
  224. #else
  225. #define yyin code_in
  226. #endif
  227. #ifdef yyout
  228. #define code_out_ALREADY_DEFINED
  229. #else
  230. #define yyout code_out
  231. #endif
  232. #ifdef yy_flex_debug
  233. #define code__flex_debug_ALREADY_DEFINED
  234. #else
  235. #define yy_flex_debug code__flex_debug
  236. #endif
  237. #ifdef yylineno
  238. #define code_lineno_ALREADY_DEFINED
  239. #else
  240. #define yylineno code_lineno
  241. #endif
  242. /* %endif */
  243. /* First, we deal with platform-specific or compiler-specific issues. */
  244. /* begin standard C headers. */
  245. /* %if-c-only */
  246. #include <stdio.h>
  247. #include <string.h>
  248. #include <errno.h>
  249. #include <stdlib.h>
  250. /* %endif */
  251. /* %if-tables-serialization */
  252. /* %endif */
  253. /* end standard C headers. */
  254. /* %if-c-or-c++ */
  255. /* flex integer type definitions */
  256. #ifndef FLEXINT_H
  257. #define FLEXINT_H
  258. /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
  259. #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  260. /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
  261. * if you want the limit (max/min) macros for int types.
  262. */
  263. #ifndef __STDC_LIMIT_MACROS
  264. #define __STDC_LIMIT_MACROS 1
  265. #endif
  266. #include <inttypes.h>
  267. typedef int8_t flex_int8_t;
  268. typedef uint8_t flex_uint8_t;
  269. typedef int16_t flex_int16_t;
  270. typedef uint16_t flex_uint16_t;
  271. typedef int32_t flex_int32_t;
  272. typedef uint32_t flex_uint32_t;
  273. #else
  274. typedef signed char flex_int8_t;
  275. typedef short int flex_int16_t;
  276. typedef int flex_int32_t;
  277. typedef unsigned char flex_uint8_t;
  278. typedef unsigned short int flex_uint16_t;
  279. typedef unsigned int flex_uint32_t;
  280. /* Limits of integral types. */
  281. #ifndef INT8_MIN
  282. #define INT8_MIN (-128)
  283. #endif
  284. #ifndef INT16_MIN
  285. #define INT16_MIN (-32767-1)
  286. #endif
  287. #ifndef INT32_MIN
  288. #define INT32_MIN (-2147483647-1)
  289. #endif
  290. #ifndef INT8_MAX
  291. #define INT8_MAX (127)
  292. #endif
  293. #ifndef INT16_MAX
  294. #define INT16_MAX (32767)
  295. #endif
  296. #ifndef INT32_MAX
  297. #define INT32_MAX (2147483647)
  298. #endif
  299. #ifndef UINT8_MAX
  300. #define UINT8_MAX (255U)
  301. #endif
  302. #ifndef UINT16_MAX
  303. #define UINT16_MAX (65535U)
  304. #endif
  305. #ifndef UINT32_MAX
  306. #define UINT32_MAX (4294967295U)
  307. #endif
  308. #ifndef SIZE_MAX
  309. #define SIZE_MAX (~(size_t)0)
  310. #endif
  311. #endif /* ! C99 */
  312. #endif /* ! FLEXINT_H */
  313. /* %endif */
  314. /* begin standard C++ headers. */
  315. /* %if-c++-only */
  316. /* %endif */
  317. /* TODO: this is always defined, so inline it */
  318. #define yyconst const
  319. #if defined(__GNUC__) && __GNUC__ >= 3
  320. #define yynoreturn __attribute__((__noreturn__))
  321. #else
  322. #define yynoreturn
  323. #endif
  324. /* %not-for-header */
  325. /* Returned upon end-of-file. */
  326. #define YY_NULL 0
  327. /* %ok-for-header */
  328. /* %not-for-header */
  329. /* Promotes a possibly negative, possibly signed char to an
  330. * integer in range [0..255] for use as an array index.
  331. */
  332. #define YY_SC_TO_UI(c) ((YY_CHAR) (c))
  333. /* %ok-for-header */
  334. /* %if-reentrant */
  335. /* %endif */
  336. /* %if-not-reentrant */
  337. /* %endif */
  338. /* Enter a start condition. This macro really ought to take a parameter,
  339. * but we do it the disgusting crufty way forced on us by the ()-less
  340. * definition of BEGIN.
  341. */
  342. #define BEGIN (yy_start) = 1 + 2 *
  343. /* Translate the current start state into a value that can be later handed
  344. * to BEGIN to return to the state. The YYSTATE alias is for lex
  345. * compatibility.
  346. */
  347. #define YY_START (((yy_start) - 1) / 2)
  348. #define YYSTATE YY_START
  349. /* Action number for EOF rule of a given start state. */
  350. #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
  351. /* Special action meaning "start processing a new file". */
  352. #define YY_NEW_FILE yyrestart( yyin )
  353. #define YY_END_OF_BUFFER_CHAR 0
  354. /* Size of default input buffer. */
  355. #ifndef YY_BUF_SIZE
  356. #ifdef __ia64__
  357. /* On IA-64, the buffer size is 16k, not 8k.
  358. * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
  359. * Ditto for the __ia64__ case accordingly.
  360. */
  361. #define YY_BUF_SIZE 32768
  362. #else
  363. #define YY_BUF_SIZE 16384
  364. #endif /* __ia64__ */
  365. #endif
  366. /* The state buf must be large enough to hold one state per character in the main buffer.
  367. */
  368. #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
  369. #ifndef YY_TYPEDEF_YY_BUFFER_STATE
  370. #define YY_TYPEDEF_YY_BUFFER_STATE
  371. typedef struct yy_buffer_state *YY_BUFFER_STATE;
  372. #endif
  373. #ifndef YY_TYPEDEF_YY_SIZE_T
  374. #define YY_TYPEDEF_YY_SIZE_T
  375. typedef size_t yy_size_t;
  376. #endif
  377. /* %if-not-reentrant */
  378. extern int yyleng;
  379. /* %endif */
  380. /* %if-c-only */
  381. /* %if-not-reentrant */
  382. extern FILE *yyin, *yyout;
  383. /* %endif */
  384. /* %endif */
  385. #define EOB_ACT_CONTINUE_SCAN 0
  386. #define EOB_ACT_END_OF_FILE 1
  387. #define EOB_ACT_LAST_MATCH 2
  388. #define YY_LESS_LINENO(n)
  389. #define YY_LINENO_REWIND_TO(ptr)
  390. /* Return all but the first "n" matched characters back to the input stream. */
  391. #define yyless(n) \
  392. do \
  393. { \
  394. /* Undo effects of setting up yytext. */ \
  395. int yyless_macro_arg = (n); \
  396. YY_LESS_LINENO(yyless_macro_arg);\
  397. *yy_cp = (yy_hold_char); \
  398. YY_RESTORE_YY_MORE_OFFSET \
  399. (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
  400. YY_DO_BEFORE_ACTION; /* set up yytext again */ \
  401. } \
  402. while ( 0 )
  403. #define unput(c) yyunput( c, (yytext_ptr) )
  404. #ifndef YY_STRUCT_YY_BUFFER_STATE
  405. #define YY_STRUCT_YY_BUFFER_STATE
  406. struct yy_buffer_state
  407. {
  408. /* %if-c-only */
  409. FILE *yy_input_file;
  410. /* %endif */
  411. /* %if-c++-only */
  412. /* %endif */
  413. char *yy_ch_buf; /* input buffer */
  414. char *yy_buf_pos; /* current position in input buffer */
  415. /* Size of input buffer in bytes, not including room for EOB
  416. * characters.
  417. */
  418. int yy_buf_size;
  419. /* Number of characters read into yy_ch_buf, not including EOB
  420. * characters.
  421. */
  422. int yy_n_chars;
  423. /* Whether we "own" the buffer - i.e., we know we created it,
  424. * and can realloc() it to grow it, and should free() it to
  425. * delete it.
  426. */
  427. int yy_is_our_buffer;
  428. /* Whether this is an "interactive" input source; if so, and
  429. * if we're using stdio for input, then we want to use getc()
  430. * instead of fread(), to make sure we stop fetching input after
  431. * each newline.
  432. */
  433. int yy_is_interactive;
  434. /* Whether we're considered to be at the beginning of a line.
  435. * If so, '^' rules will be active on the next match, otherwise
  436. * not.
  437. */
  438. int yy_at_bol;
  439. int yy_bs_lineno; /**< The line count. */
  440. int yy_bs_column; /**< The column count. */
  441. /* Whether to try to fill the input buffer when we reach the
  442. * end of it.
  443. */
  444. int yy_fill_buffer;
  445. int yy_buffer_status;
  446. #define YY_BUFFER_NEW 0
  447. #define YY_BUFFER_NORMAL 1
  448. /* When an EOF's been seen but there's still some text to process
  449. * then we mark the buffer as YY_EOF_PENDING, to indicate that we
  450. * shouldn't try reading from the input source any more. We might
  451. * still have a bunch of tokens to match, though, because of
  452. * possible backing-up.
  453. *
  454. * When we actually see the EOF, we change the status to "new"
  455. * (via yyrestart()), so that the user can continue scanning by
  456. * just pointing yyin at a new input file.
  457. */
  458. #define YY_BUFFER_EOF_PENDING 2
  459. };
  460. #endif /* !YY_STRUCT_YY_BUFFER_STATE */
  461. /* %if-c-only Standard (non-C++) definition */
  462. /* %not-for-header */
  463. /* %if-not-reentrant */
  464. /* Stack of input buffers. */
  465. static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
  466. static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
  467. static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */
  468. /* %endif */
  469. /* %ok-for-header */
  470. /* %endif */
  471. /* We provide macros for accessing buffer states in case in the
  472. * future we want to put the buffer states in a more general
  473. * "scanner state".
  474. *
  475. * Returns the top of the stack, or NULL.
  476. */
  477. #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
  478. ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
  479. : NULL)
  480. /* Same as previous macro, but useful when we know that the buffer stack is not
  481. * NULL or when we need an lvalue. For internal use only.
  482. */
  483. #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
  484. /* %if-c-only Standard (non-C++) definition */
  485. /* %if-not-reentrant */
  486. /* %not-for-header */
  487. /* yy_hold_char holds the character lost when yytext is formed. */
  488. static char yy_hold_char;
  489. static int yy_n_chars; /* number of characters read into yy_ch_buf */
  490. int yyleng;
  491. /* Points to current character in buffer. */
  492. static char *yy_c_buf_p = NULL;
  493. static int yy_init = 0; /* whether we need to initialize */
  494. static int yy_start = 0; /* start state number */
  495. /* Flag which is used to allow yywrap()'s to do buffer switches
  496. * instead of setting up a fresh yyin. A bit of a hack ...
  497. */
  498. static int yy_did_buffer_switch_on_eof;
  499. /* %ok-for-header */
  500. /* %endif */
  501. void yyrestart ( FILE *input_file );
  502. void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer );
  503. YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size );
  504. void yy_delete_buffer ( YY_BUFFER_STATE b );
  505. void yy_flush_buffer ( YY_BUFFER_STATE b );
  506. void yypush_buffer_state ( YY_BUFFER_STATE new_buffer );
  507. void yypop_buffer_state ( void );
  508. static void yyensure_buffer_stack ( void );
  509. static void yy_load_buffer_state ( void );
  510. static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file );
  511. #define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER )
  512. YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size );
  513. YY_BUFFER_STATE yy_scan_string ( const char *yy_str );
  514. YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len );
  515. /* %endif */
  516. void *yyalloc ( yy_size_t );
  517. void *yyrealloc ( void *, yy_size_t );
  518. void yyfree ( void * );
  519. #define yy_new_buffer yy_create_buffer
  520. #define yy_set_interactive(is_interactive) \
  521. { \
  522. if ( ! YY_CURRENT_BUFFER ){ \
  523. yyensure_buffer_stack (); \
  524. YY_CURRENT_BUFFER_LVALUE = \
  525. yy_create_buffer( yyin, YY_BUF_SIZE ); \
  526. } \
  527. YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
  528. }
  529. #define yy_set_bol(at_bol) \
  530. { \
  531. if ( ! YY_CURRENT_BUFFER ){\
  532. yyensure_buffer_stack (); \
  533. YY_CURRENT_BUFFER_LVALUE = \
  534. yy_create_buffer( yyin, YY_BUF_SIZE ); \
  535. } \
  536. YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
  537. }
  538. #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
  539. /* %% [1.0] yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here */
  540. /* Begin user sect3 */
  541. #define code_wrap() (/*CONSTCOND*/1)
  542. #define YY_SKIP_YYWRAP
  543. #define FLEX_DEBUG
  544. typedef flex_uint8_t YY_CHAR;
  545. FILE *yyin = NULL, *yyout = NULL;
  546. typedef int yy_state_type;
  547. extern int yylineno;
  548. int yylineno = 1;
  549. extern char *yytext;
  550. #ifdef yytext_ptr
  551. #undef yytext_ptr
  552. #endif
  553. #define yytext_ptr yytext
  554. /* %% [1.5] DFA */
  555. /* %if-c-only Standard (non-C++) definition */
  556. static yy_state_type yy_get_previous_state ( void );
  557. static yy_state_type yy_try_NUL_trans ( yy_state_type current_state );
  558. static int yy_get_next_buffer ( void );
  559. static void yynoreturn yy_fatal_error ( const char* msg );
  560. /* %endif */
  561. /* Done after the current pattern has been matched and before the
  562. * corresponding action - sets up yytext.
  563. */
  564. #define YY_DO_BEFORE_ACTION \
  565. (yytext_ptr) = yy_bp; \
  566. /* %% [2.0] code to fiddle yytext and yyleng for yymore() goes here \ */\
  567. yyleng = (int) (yy_cp - yy_bp); \
  568. (yy_hold_char) = *yy_cp; \
  569. *yy_cp = '\0'; \
  570. /* %% [3.0] code to copy yytext_ptr to yytext[] goes here, if %array \ */\
  571. (yy_c_buf_p) = yy_cp;
  572. /* %% [4.0] data tables for the DFA and the user's section 1 definitions go here */
  573. #define YY_NUM_RULES 18
  574. #define YY_END_OF_BUFFER 19
  575. /* This struct is not used in this scanner,
  576. but its presence is necessary. */
  577. struct yy_trans_info
  578. {
  579. flex_int32_t yy_verify;
  580. flex_int32_t yy_nxt;
  581. };
  582. static const flex_int16_t yy_accept[82] =
  583. { 0,
  584. 0, 0, 0, 0, 3, 3, 4, 4, 4, 4,
  585. 0, 0, 0, 0, 19, 17, 16, 17, 2, 17,
  586. 6, 17, 5, 8, 11, 7, 17, 11, 11, 11,
  587. 1, 0, 0, 3, 4, 4, 4, 4, 12, 0,
  588. 12, 12, 0, 0, 9, 10, 0, 13, 0, 13,
  589. 13, 0, 14, 0, 15, 0, 0, 0, 0, 0,
  590. 0, 0, 12, 0, 0, 0, 0, 0, 0, 13,
  591. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  592. 0
  593. } ;
  594. static const YY_CHAR yy_ec[256] =
  595. { 0,
  596. 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
  597. 2, 2, 1, 1, 1, 1, 1, 1, 1, 1,
  598. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  599. 1, 2, 1, 4, 1, 5, 1, 1, 6, 1,
  600. 1, 7, 1, 1, 8, 9, 10, 11, 11, 11,
  601. 11, 11, 11, 11, 11, 11, 11, 1, 1, 12,
  602. 1, 13, 1, 14, 9, 9, 9, 9, 9, 9,
  603. 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
  604. 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
  605. 15, 16, 17, 1, 9, 1, 9, 9, 9, 9,
  606. 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
  607. 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
  608. 9, 9, 1, 1, 1, 1, 1, 1, 1, 1,
  609. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  610. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  611. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  612. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  613. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  614. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  615. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  616. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  617. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  618. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  619. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  620. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  621. 1, 1, 1, 1, 1
  622. } ;
  623. static const YY_CHAR yy_meta[19] =
  624. { 0,
  625. 1, 1, 1, 1, 1, 1, 1, 2, 2, 1,
  626. 2, 1, 1, 1, 1, 1, 1, 1
  627. } ;
  628. static const flex_int16_t yy_base[88] =
  629. { 0,
  630. 0, 13, 101, 100, 0, 3, 4, 5, 6, 7,
  631. 27, 0, 20, 21, 104, 182, 182, 26, 182, 8,
  632. 182, 41, 182, 182, 53, 182, 62, 74, 33, 98,
  633. 182, 37, 44, 86, 182, 46, 85, 48, 182, 88,
  634. 0, 87, 87, 87, 182, 182, 50, 182, 83, 0,
  635. 82, 79, 182, 103, 182, 52, 50, 68, 71, 73,
  636. 78, 81, 0, 119, 64, 50, 130, 84, 0, 0,
  637. 140, 155, 43, 16, 79, 12, 0, 0, 54, 2,
  638. 182, 173, 175, 2, 177, 0, 179
  639. } ;
  640. static const flex_int16_t yy_def[88] =
  641. { 0,
  642. 82, 82, 2, 2, 2, 2, 2, 2, 2, 2,
  643. 2, 11, 11, 11, 81, 81, 81, 81, 81, 81,
  644. 81, 83, 81, 81, 81, 81, 81, 81, 81, 81,
  645. 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
  646. 84, 81, 85, 81, 81, 81, 81, 81, 81, 86,
  647. 81, 81, 81, 87, 81, 81, 81, 81, 81, 81,
  648. 81, 83, 84, 85, 81, 64, 81, 81, 27, 86,
  649. 81, 87, 81, 72, 25, 25, 67, 71, 81, 81,
  650. 0, 81, 81, 81, 81, 81, 81
  651. } ;
  652. static const flex_int16_t yy_nxt[201] =
  653. { 0,
  654. 81, 70, 19, 63, 17, 19, 53, 21, 21, 33,
  655. 34, 23, 23, 17, 17, 20, 17, 17, 20, 22,
  656. 22, 22, 22, 81, 29, 29, 17, 17, 72, 17,
  657. 24, 25, 26, 30, 30, 31, 27, 53, 56, 57,
  658. 28, 32, 36, 37, 54, 33, 34, 59, 37, 61,
  659. 62, 68, 69, 56, 57, 80, 38, 39, 53, 31,
  660. 40, 41, 64, 42, 43, 32, 80, 44, 45, 33,
  661. 34, 46, 59, 37, 59, 37, 76, 47, 48, 61,
  662. 62, 49, 50, 81, 51, 68, 69, 71, 52, 65,
  663. 81, 76, 51, 51, 66, 67, 38, 42, 42, 65,
  664. 60, 58, 55, 81, 65, 73, 18, 18, 81, 81,
  665. 74, 81, 81, 81, 81, 73, 81, 81, 81, 81,
  666. 73, 65, 81, 81, 81, 81, 66, 81, 81, 81,
  667. 81, 75, 81, 81, 81, 81, 65, 77, 77, 81,
  668. 77, 81, 81, 81, 81, 81, 39, 78, 78, 81,
  669. 78, 81, 81, 81, 81, 81, 48, 73, 81, 81,
  670. 81, 81, 74, 81, 81, 81, 81, 79, 81, 81,
  671. 81, 81, 73, 16, 16, 35, 35, 64, 64, 72,
  672. 72, 15, 81, 81, 81, 81, 81, 81, 81, 81,
  673. 81, 81, 81, 81, 81, 81, 81, 81, 81, 81
  674. } ;
  675. static const flex_int16_t yy_chk[201] =
  676. { 0,
  677. 0, 86, 5, 84, 1, 6, 80, 7, 8, 20,
  678. 20, 9, 10, 1, 1, 5, 1, 2, 6, 7,
  679. 8, 9, 10, 76, 13, 14, 2, 2, 74, 2,
  680. 11, 11, 11, 13, 14, 18, 11, 29, 32, 32,
  681. 11, 18, 22, 22, 29, 33, 33, 36, 36, 38,
  682. 38, 47, 47, 56, 56, 73, 22, 25, 79, 57,
  683. 25, 25, 66, 25, 25, 57, 79, 25, 27, 58,
  684. 58, 27, 59, 59, 60, 60, 65, 27, 28, 61,
  685. 61, 28, 28, 62, 28, 68, 68, 52, 28, 43,
  686. 75, 75, 51, 49, 43, 44, 62, 42, 40, 43,
  687. 37, 34, 30, 15, 43, 54, 4, 3, 0, 0,
  688. 54, 0, 0, 0, 0, 54, 0, 0, 0, 0,
  689. 54, 64, 0, 0, 0, 0, 64, 0, 0, 0,
  690. 0, 64, 0, 0, 0, 0, 64, 67, 67, 0,
  691. 67, 0, 0, 0, 0, 0, 67, 71, 71, 0,
  692. 71, 0, 0, 0, 0, 0, 71, 72, 0, 0,
  693. 0, 0, 72, 0, 0, 0, 0, 72, 0, 0,
  694. 0, 0, 72, 82, 82, 83, 83, 85, 85, 87,
  695. 87, 81, 81, 81, 81, 81, 81, 81, 81, 81,
  696. 81, 81, 81, 81, 81, 81, 81, 81, 81, 81
  697. } ;
  698. static yy_state_type yy_last_accepting_state;
  699. static char *yy_last_accepting_cpos;
  700. extern int yy_flex_debug;
  701. int yy_flex_debug = 1;
  702. static const flex_int16_t yy_rule_linenum[18] =
  703. { 0,
  704. 116, 126, 127, 137, 142, 147, 153, 154, 155, 156,
  705. 158, 166, 172, 182, 190, 200, 203
  706. } ;
  707. /* The intent behind this definition is that it'll catch
  708. * any uses of REJECT which flex missed.
  709. */
  710. #define REJECT reject_used_but_not_detected
  711. #define yymore() yymore_used_but_not_detected
  712. #define YY_MORE_ADJ 0
  713. #define YY_RESTORE_YY_MORE_OFFSET
  714. char *yytext;
  715. #line 1 "/Users/akim/src/gnu/bison/src/scan-code.l"
  716. /* Bison Action Scanner -*- C -*-
  717. Copyright (C) 2006-2015, 2018-2021 Free Software Foundation, Inc.
  718. This file is part of Bison, the GNU Compiler Compiler.
  719. This program is free software: you can redistribute it and/or modify
  720. it under the terms of the GNU General Public License as published by
  721. the Free Software Foundation, either version 3 of the License, or
  722. (at your option) any later version.
  723. This program is distributed in the hope that it will be useful,
  724. but WITHOUT ANY WARRANTY; without even the implied warranty of
  725. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  726. GNU General Public License for more details.
  727. You should have received a copy of the GNU General Public License
  728. along with this program. If not, see <https://www.gnu.org/licenses/>. */
  729. #define YY_NO_INPUT 1
  730. #line 24 "/Users/akim/src/gnu/bison/src/scan-code.l"
  731. #include <c-ctype.h>
  732. #include <get-errno.h>
  733. #include <quote.h>
  734. #include "src/complain.h"
  735. #include "src/getargs.h"
  736. #include "src/muscle-tab.h"
  737. #include "src/reader.h"
  738. #include "src/scan-code.h"
  739. #include "src/symlist.h"
  740. #define FLEX_PREFIX(Id) code_ ## Id
  741. #include "src/flex-scanner.h"
  742. /* Work around a bug in flex 2.5.31. See Debian bug 333231
  743. <https://bugs.debian.org/333231>. */
  744. #undef code_wrap
  745. #define code_wrap() 1
  746. /* The current calling start condition: SC_RULE_ACTION or
  747. SC_SYMBOL_ACTION. */
  748. # define YY_DECL static char *code_lex (code_props *self, int sc_context)
  749. YY_DECL;
  750. #define YY_USER_ACTION location_compute (loc, &loc->end, yytext, yyleng);
  751. static char *fetch_type_name (char *cp, char const **type_name,
  752. const location *dollar_loc);
  753. static void handle_action_dollar (symbol_list *rule, char *cp,
  754. const location *dollar_loc);
  755. static void handle_action_at (symbol_list *rule, char *cp,
  756. const location *at_loc);
  757. /* A string to be pushed to obstack after dollar/at has been handled. */
  758. static char *ref_tail_fields;
  759. static location current_loc;
  760. static location *loc = &current_loc;
  761. /* A string representing the most recent translation. */
  762. static char *last_string;
  763. /* True if an untyped $$ or $n was seen. */
  764. static bool untyped_var_seen;
  765. #line 919 "src/scan-code.c"
  766. #line 72 "/Users/akim/src/gnu/bison/src/scan-code.l"
  767. /* C and C++ comments in code. */
  768. /* Strings and characters in code. */
  769. /* Whether in a rule or symbol action. Specifies the translation
  770. of $ and @. */
  771. /* POSIX says that a tag must be both an id and a C union member, but
  772. historically almost any character is allowed in a tag. We disallow
  773. NUL and newline, as this simplifies our implementation. We allow
  774. "->" as a means to dereference a pointer. */
  775. /* Zero or more instances of backslash-newline. Following GCC, allow
  776. white space between the backslash and the newline. */
  777. /* C style identifier. Must start with letter. Will be used for
  778. named symbol references. Shall be kept synchronized with
  779. scan-gram.l "letter" and "id". */
  780. #line 937 "src/scan-code.c"
  781. #define INITIAL 0
  782. #define SC_COMMENT 1
  783. #define SC_LINE_COMMENT 2
  784. #define SC_STRING 3
  785. #define SC_CHARACTER 4
  786. #define SC_RULE_ACTION 5
  787. #define SC_SYMBOL_ACTION 6
  788. #ifndef YY_NO_UNISTD_H
  789. /* Special case for "unistd.h", since it is non-ANSI. We include it way
  790. * down here because we want the user's section 1 to have been scanned first.
  791. * The user has a chance to override it with an option.
  792. */
  793. /* %if-c-only */
  794. #include <unistd.h>
  795. /* %endif */
  796. /* %if-c++-only */
  797. /* %endif */
  798. #endif
  799. #ifndef YY_EXTRA_TYPE
  800. #define YY_EXTRA_TYPE void *
  801. #endif
  802. /* %if-c-only Reentrant structure and macros (non-C++). */
  803. /* %if-reentrant */
  804. /* %if-c-only */
  805. static int yy_init_globals ( void );
  806. /* %endif */
  807. /* %if-reentrant */
  808. /* %endif */
  809. /* %endif End reentrant structures and macros. */
  810. /* Accessor methods to globals.
  811. These are made visible to non-reentrant scanners for convenience. */
  812. int yylex_destroy ( void );
  813. int yyget_debug ( void );
  814. void yyset_debug ( int debug_flag );
  815. YY_EXTRA_TYPE yyget_extra ( void );
  816. void yyset_extra ( YY_EXTRA_TYPE user_defined );
  817. FILE *yyget_in ( void );
  818. void yyset_in ( FILE * _in_str );
  819. FILE *yyget_out ( void );
  820. void yyset_out ( FILE * _out_str );
  821. int yyget_leng ( void );
  822. char *yyget_text ( void );
  823. int yyget_lineno ( void );
  824. void yyset_lineno ( int _line_number );
  825. /* %if-bison-bridge */
  826. /* %endif */
  827. /* Macros after this point can all be overridden by user definitions in
  828. * section 1.
  829. */
  830. #ifndef YY_SKIP_YYWRAP
  831. #ifdef __cplusplus
  832. extern "C" int yywrap ( void );
  833. #else
  834. extern int yywrap ( void );
  835. #endif
  836. #endif
  837. /* %not-for-header */
  838. #ifndef YY_NO_UNPUT
  839. #endif
  840. /* %ok-for-header */
  841. /* %endif */
  842. #ifndef yytext_ptr
  843. static void yy_flex_strncpy ( char *, const char *, int );
  844. #endif
  845. #ifdef YY_NEED_STRLEN
  846. static int yy_flex_strlen ( const char * );
  847. #endif
  848. #ifndef YY_NO_INPUT
  849. /* %if-c-only Standard (non-C++) definition */
  850. /* %not-for-header */
  851. #ifdef __cplusplus
  852. static int yyinput ( void );
  853. #else
  854. static int input ( void );
  855. #endif
  856. /* %ok-for-header */
  857. /* %endif */
  858. #endif
  859. /* %if-c-only */
  860. /* %endif */
  861. /* Amount of stuff to slurp up with each read. */
  862. #ifndef YY_READ_BUF_SIZE
  863. #ifdef __ia64__
  864. /* On IA-64, the buffer size is 16k, not 8k */
  865. #define YY_READ_BUF_SIZE 16384
  866. #else
  867. #define YY_READ_BUF_SIZE 8192
  868. #endif /* __ia64__ */
  869. #endif
  870. /* Copy whatever the last rule matched to the standard output. */
  871. #ifndef ECHO
  872. /* %if-c-only Standard (non-C++) definition */
  873. /* This used to be an fputs(), but since the string might contain NUL's,
  874. * we now use fwrite().
  875. */
  876. #define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0)
  877. /* %endif */
  878. /* %if-c++-only C++ definition */
  879. /* %endif */
  880. #endif
  881. /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
  882. * is returned in "result".
  883. */
  884. #ifndef YY_INPUT
  885. #define YY_INPUT(buf,result,max_size) \
  886. /* %% [5.0] fread()/read() definition of YY_INPUT goes here unless we're doing C++ \ */\
  887. if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
  888. { \
  889. int c = '*'; \
  890. int n; \
  891. for ( n = 0; n < max_size && \
  892. (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
  893. buf[n] = (char) c; \
  894. if ( c == '\n' ) \
  895. buf[n++] = (char) c; \
  896. if ( c == EOF && ferror( yyin ) ) \
  897. YY_FATAL_ERROR( "input in flex scanner failed" ); \
  898. result = n; \
  899. } \
  900. else \
  901. { \
  902. errno=0; \
  903. while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \
  904. { \
  905. if( errno != EINTR) \
  906. { \
  907. YY_FATAL_ERROR( "input in flex scanner failed" ); \
  908. break; \
  909. } \
  910. errno=0; \
  911. clearerr(yyin); \
  912. } \
  913. }\
  914. \
  915. /* %if-c++-only C++ definition \ */\
  916. /* %endif */
  917. #endif
  918. /* No semi-colon after return; correct usage is to write "yyterminate();" -
  919. * we don't want an extra ';' after the "return" because that will cause
  920. * some compilers to complain about unreachable statements.
  921. */
  922. #ifndef yyterminate
  923. #define yyterminate() return YY_NULL
  924. #endif
  925. /* Number of entries by which start-condition stack grows. */
  926. #ifndef YY_START_STACK_INCR
  927. #define YY_START_STACK_INCR 25
  928. #endif
  929. /* Report a fatal error. */
  930. #ifndef YY_FATAL_ERROR
  931. /* %if-c-only */
  932. #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
  933. /* %endif */
  934. /* %if-c++-only */
  935. /* %endif */
  936. #endif
  937. /* %if-tables-serialization structures and prototypes */
  938. /* %not-for-header */
  939. /* %ok-for-header */
  940. /* %not-for-header */
  941. /* %tables-yydmap generated elements */
  942. /* %endif */
  943. /* end tables serialization structures and prototypes */
  944. /* %ok-for-header */
  945. /* Default declaration of generated scanner - a define so the user can
  946. * easily add parameters.
  947. */
  948. #ifndef YY_DECL
  949. #define YY_DECL_IS_OURS 1
  950. /* %if-c-only Standard (non-C++) definition */
  951. extern int yylex (void);
  952. #define YY_DECL int yylex (void)
  953. /* %endif */
  954. /* %if-c++-only C++ definition */
  955. /* %endif */
  956. #endif /* !YY_DECL */
  957. /* Code executed at the beginning of each rule, after yytext and yyleng
  958. * have been set up.
  959. */
  960. #ifndef YY_USER_ACTION
  961. #define YY_USER_ACTION
  962. #endif
  963. /* Code executed at the end of each rule. */
  964. #ifndef YY_BREAK
  965. #define YY_BREAK /*LINTED*/break;
  966. #endif
  967. /* %% [6.0] YY_RULE_SETUP definition goes here */
  968. #define YY_RULE_SETUP \
  969. YY_USER_ACTION
  970. /* %not-for-header */
  971. /** The main scanner function which does all the work.
  972. */
  973. YY_DECL
  974. {
  975. yy_state_type yy_current_state;
  976. char *yy_cp, *yy_bp;
  977. int yy_act;
  978. if ( !(yy_init) )
  979. {
  980. (yy_init) = 1;
  981. #ifdef YY_USER_INIT
  982. YY_USER_INIT;
  983. #endif
  984. if ( ! (yy_start) )
  985. (yy_start) = 1; /* first start state */
  986. if ( ! yyin )
  987. /* %if-c-only */
  988. yyin = stdin;
  989. /* %endif */
  990. /* %if-c++-only */
  991. /* %endif */
  992. if ( ! yyout )
  993. /* %if-c-only */
  994. yyout = stdout;
  995. /* %endif */
  996. /* %if-c++-only */
  997. /* %endif */
  998. if ( ! YY_CURRENT_BUFFER ) {
  999. yyensure_buffer_stack ();
  1000. YY_CURRENT_BUFFER_LVALUE =
  1001. yy_create_buffer( yyin, YY_BUF_SIZE );
  1002. }
  1003. yy_load_buffer_state( );
  1004. }
  1005. {
  1006. /* %% [7.0] user's declarations go here */
  1007. #line 98 "/Users/akim/src/gnu/bison/src/scan-code.l"
  1008. /* This scanner is special: it is invoked only once, henceforth
  1009. is expected to return only once. This initialization is
  1010. therefore done once per action to translate. */
  1011. aver (sc_context == SC_SYMBOL_ACTION
  1012. || sc_context == SC_RULE_ACTION
  1013. || sc_context == INITIAL);
  1014. BEGIN sc_context;
  1015. /*------------------------------------------------------------.
  1016. | Scanning a C comment. The initial '/ *' is already eaten. |
  1017. `------------------------------------------------------------*/
  1018. #line 1238 "src/scan-code.c"
  1019. while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
  1020. {
  1021. /* %% [8.0] yymore()-related code goes here */
  1022. yy_cp = (yy_c_buf_p);
  1023. /* Support of yytext. */
  1024. *yy_cp = (yy_hold_char);
  1025. /* yy_bp points to the position in yy_ch_buf of the start of
  1026. * the current run.
  1027. */
  1028. yy_bp = yy_cp;
  1029. /* %% [9.0] code to set up and find next match goes here */
  1030. yy_current_state = (yy_start);
  1031. yy_match:
  1032. do
  1033. {
  1034. YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
  1035. if ( yy_accept[yy_current_state] )
  1036. {
  1037. (yy_last_accepting_state) = yy_current_state;
  1038. (yy_last_accepting_cpos) = yy_cp;
  1039. }
  1040. while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  1041. {
  1042. yy_current_state = (int) yy_def[yy_current_state];
  1043. if ( yy_current_state >= 82 )
  1044. yy_c = yy_meta[yy_c];
  1045. }
  1046. yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
  1047. ++yy_cp;
  1048. }
  1049. while ( yy_current_state != 81 );
  1050. yy_cp = (yy_last_accepting_cpos);
  1051. yy_current_state = (yy_last_accepting_state);
  1052. yy_find_action:
  1053. /* %% [10.0] code to find the action number goes here */
  1054. yy_act = yy_accept[yy_current_state];
  1055. YY_DO_BEFORE_ACTION;
  1056. /* %% [11.0] code for yylineno update goes here */
  1057. do_action: /* This label is used only to access EOF actions. */
  1058. /* %% [12.0] debug code goes here */
  1059. if ( yy_flex_debug )
  1060. {
  1061. if ( yy_act == 0 )
  1062. fprintf( stderr, "--scanner backing up\n" );
  1063. else if ( yy_act < 18 )
  1064. fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n",
  1065. (long)yy_rule_linenum[yy_act], yytext );
  1066. else if ( yy_act == 18 )
  1067. fprintf( stderr, "--accepting default rule (\"%s\")\n",
  1068. yytext );
  1069. else if ( yy_act == 19 )
  1070. fprintf( stderr, "--(end of buffer or a NUL)\n" );
  1071. else
  1072. fprintf( stderr, "--EOF (start condition %d)\n", YY_START );
  1073. }
  1074. switch ( yy_act )
  1075. { /* beginning of action switch */
  1076. /* %% [13.0] actions go here */
  1077. case 0: /* must back up */
  1078. /* undo the effects of YY_DO_BEFORE_ACTION */
  1079. *yy_cp = (yy_hold_char);
  1080. yy_cp = (yy_last_accepting_cpos);
  1081. yy_current_state = (yy_last_accepting_state);
  1082. goto yy_find_action;
  1083. case 1:
  1084. /* rule 1 can match eol */
  1085. YY_RULE_SETUP
  1086. #line 116 "/Users/akim/src/gnu/bison/src/scan-code.l"
  1087. STRING_GROW (); BEGIN sc_context;
  1088. YY_BREAK
  1089. /*--------------------------------------------------------------.
  1090. | Scanning a line comment. The initial '//' is already eaten. |
  1091. `--------------------------------------------------------------*/
  1092. case 2:
  1093. /* rule 2 can match eol */
  1094. YY_RULE_SETUP
  1095. #line 126 "/Users/akim/src/gnu/bison/src/scan-code.l"
  1096. STRING_GROW (); BEGIN sc_context;
  1097. YY_BREAK
  1098. case 3:
  1099. /* rule 3 can match eol */
  1100. YY_RULE_SETUP
  1101. #line 127 "/Users/akim/src/gnu/bison/src/scan-code.l"
  1102. STRING_GROW ();
  1103. YY_BREAK
  1104. /*--------------------------------------------.
  1105. | Scanning user-code characters and strings. |
  1106. `--------------------------------------------*/
  1107. case 4:
  1108. /* rule 4 can match eol */
  1109. YY_RULE_SETUP
  1110. #line 137 "/Users/akim/src/gnu/bison/src/scan-code.l"
  1111. STRING_GROW ();
  1112. YY_BREAK
  1113. case 5:
  1114. YY_RULE_SETUP
  1115. #line 142 "/Users/akim/src/gnu/bison/src/scan-code.l"
  1116. STRING_GROW (); BEGIN sc_context;
  1117. YY_BREAK
  1118. case 6:
  1119. YY_RULE_SETUP
  1120. #line 147 "/Users/akim/src/gnu/bison/src/scan-code.l"
  1121. STRING_GROW (); BEGIN sc_context;
  1122. YY_BREAK
  1123. case 7:
  1124. YY_RULE_SETUP
  1125. #line 153 "/Users/akim/src/gnu/bison/src/scan-code.l"
  1126. STRING_GROW (); BEGIN SC_CHARACTER;
  1127. YY_BREAK
  1128. case 8:
  1129. YY_RULE_SETUP
  1130. #line 154 "/Users/akim/src/gnu/bison/src/scan-code.l"
  1131. STRING_GROW (); BEGIN SC_STRING;
  1132. YY_BREAK
  1133. case 9:
  1134. /* rule 9 can match eol */
  1135. YY_RULE_SETUP
  1136. #line 155 "/Users/akim/src/gnu/bison/src/scan-code.l"
  1137. STRING_GROW (); BEGIN SC_COMMENT;
  1138. YY_BREAK
  1139. case 10:
  1140. /* rule 10 can match eol */
  1141. YY_RULE_SETUP
  1142. #line 156 "/Users/akim/src/gnu/bison/src/scan-code.l"
  1143. STRING_GROW (); BEGIN SC_LINE_COMMENT;
  1144. YY_BREAK
  1145. case 11:
  1146. YY_RULE_SETUP
  1147. #line 158 "/Users/akim/src/gnu/bison/src/scan-code.l"
  1148. {
  1149. complain (loc, Wother, _("stray '%s'"), yytext);
  1150. obstack_escape (&obstack_for_string, yytext);
  1151. }
  1152. YY_BREAK
  1153. case 12:
  1154. /* rule 12 can match eol */
  1155. YY_RULE_SETUP
  1156. #line 166 "/Users/akim/src/gnu/bison/src/scan-code.l"
  1157. {
  1158. ref_tail_fields = NULL;
  1159. handle_action_dollar (self->rule, yytext, loc);
  1160. if (ref_tail_fields)
  1161. obstack_sgrow (&obstack_for_string, ref_tail_fields);
  1162. }
  1163. YY_BREAK
  1164. case 13:
  1165. YY_RULE_SETUP
  1166. #line 172 "/Users/akim/src/gnu/bison/src/scan-code.l"
  1167. {
  1168. ref_tail_fields = NULL;
  1169. handle_action_at (self->rule, yytext, loc);
  1170. if (ref_tail_fields)
  1171. obstack_sgrow (&obstack_for_string, ref_tail_fields);
  1172. }
  1173. YY_BREAK
  1174. case 14:
  1175. /* rule 14 can match eol */
  1176. YY_RULE_SETUP
  1177. #line 182 "/Users/akim/src/gnu/bison/src/scan-code.l"
  1178. {
  1179. const char *type_name = NULL;
  1180. fetch_type_name (yytext + 1, &type_name, loc)[-1] = 0;
  1181. obstack_sgrow (&obstack_for_string, "]b4_dollar_dollar(");
  1182. obstack_quote (&obstack_for_string, type_name);
  1183. obstack_sgrow (&obstack_for_string, ")[");
  1184. self->is_value_used = true;
  1185. }
  1186. YY_BREAK
  1187. case 15:
  1188. YY_RULE_SETUP
  1189. #line 190 "/Users/akim/src/gnu/bison/src/scan-code.l"
  1190. {
  1191. obstack_sgrow (&obstack_for_string, "]b4_at_dollar[");
  1192. muscle_percent_define_ensure("locations", *loc, true);
  1193. }
  1194. YY_BREAK
  1195. /* Escape M4 quoting characters in C code. */
  1196. case 16:
  1197. YY_RULE_SETUP
  1198. #line 200 "/Users/akim/src/gnu/bison/src/scan-code.l"
  1199. obstack_escape (&obstack_for_string, yytext);
  1200. YY_BREAK
  1201. /* By default, grow the string obstack with the input. */
  1202. case 17:
  1203. /* rule 17 can match eol */
  1204. YY_RULE_SETUP
  1205. #line 203 "/Users/akim/src/gnu/bison/src/scan-code.l"
  1206. STRING_GROW ();
  1207. YY_BREAK
  1208. /* End of processing. */
  1209. case YY_STATE_EOF(INITIAL):
  1210. case YY_STATE_EOF(SC_COMMENT):
  1211. case YY_STATE_EOF(SC_LINE_COMMENT):
  1212. case YY_STATE_EOF(SC_STRING):
  1213. case YY_STATE_EOF(SC_CHARACTER):
  1214. case YY_STATE_EOF(SC_RULE_ACTION):
  1215. case YY_STATE_EOF(SC_SYMBOL_ACTION):
  1216. #line 206 "/Users/akim/src/gnu/bison/src/scan-code.l"
  1217. STRING_FINISH (); return last_string;
  1218. YY_BREAK
  1219. case 18:
  1220. YY_RULE_SETUP
  1221. #line 209 "/Users/akim/src/gnu/bison/src/scan-code.l"
  1222. YY_FATAL_ERROR( "flex scanner jammed" );
  1223. YY_BREAK
  1224. #line 1480 "src/scan-code.c"
  1225. case YY_END_OF_BUFFER:
  1226. {
  1227. /* Amount of text matched not including the EOB char. */
  1228. int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
  1229. /* Undo the effects of YY_DO_BEFORE_ACTION. */
  1230. *yy_cp = (yy_hold_char);
  1231. YY_RESTORE_YY_MORE_OFFSET
  1232. if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
  1233. {
  1234. /* We're scanning a new file or input source. It's
  1235. * possible that this happened because the user
  1236. * just pointed yyin at a new source and called
  1237. * yylex(). If so, then we have to assure
  1238. * consistency between YY_CURRENT_BUFFER and our
  1239. * globals. Here is the right place to do so, because
  1240. * this is the first action (other than possibly a
  1241. * back-up) that will match for the new input source.
  1242. */
  1243. (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
  1244. /* %if-c-only */
  1245. YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
  1246. /* %endif */
  1247. /* %if-c++-only */
  1248. /* %endif */
  1249. YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
  1250. }
  1251. /* Note that here we test for yy_c_buf_p "<=" to the position
  1252. * of the first EOB in the buffer, since yy_c_buf_p will
  1253. * already have been incremented past the NUL character
  1254. * (since all states make transitions on EOB to the
  1255. * end-of-buffer state). Contrast this with the test
  1256. * in input().
  1257. */
  1258. if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
  1259. { /* This was really a NUL. */
  1260. yy_state_type yy_next_state;
  1261. (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
  1262. yy_current_state = yy_get_previous_state( );
  1263. /* Okay, we're now positioned to make the NUL
  1264. * transition. We couldn't have
  1265. * yy_get_previous_state() go ahead and do it
  1266. * for us because it doesn't know how to deal
  1267. * with the possibility of jamming (and we don't
  1268. * want to build jamming into it because then it
  1269. * will run more slowly).
  1270. */
  1271. yy_next_state = yy_try_NUL_trans( yy_current_state );
  1272. yy_bp = (yytext_ptr) + YY_MORE_ADJ;
  1273. if ( yy_next_state )
  1274. {
  1275. /* Consume the NUL. */
  1276. yy_cp = ++(yy_c_buf_p);
  1277. yy_current_state = yy_next_state;
  1278. goto yy_match;
  1279. }
  1280. else
  1281. {
  1282. /* %% [14.0] code to do back-up for compressed tables and set up yy_cp goes here */
  1283. yy_cp = (yy_last_accepting_cpos);
  1284. yy_current_state = (yy_last_accepting_state);
  1285. goto yy_find_action;
  1286. }
  1287. }
  1288. else switch ( yy_get_next_buffer( ) )
  1289. {
  1290. case EOB_ACT_END_OF_FILE:
  1291. {
  1292. (yy_did_buffer_switch_on_eof) = 0;
  1293. if ( yywrap( ) )
  1294. {
  1295. /* Note: because we've taken care in
  1296. * yy_get_next_buffer() to have set up
  1297. * yytext, we can now set up
  1298. * yy_c_buf_p so that if some total
  1299. * hoser (like flex itself) wants to
  1300. * call the scanner after we return the
  1301. * YY_NULL, it'll still work - another
  1302. * YY_NULL will get returned.
  1303. */
  1304. (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
  1305. yy_act = YY_STATE_EOF(YY_START);
  1306. goto do_action;
  1307. }
  1308. else
  1309. {
  1310. if ( ! (yy_did_buffer_switch_on_eof) )
  1311. YY_NEW_FILE;
  1312. }
  1313. break;
  1314. }
  1315. case EOB_ACT_CONTINUE_SCAN:
  1316. (yy_c_buf_p) =
  1317. (yytext_ptr) + yy_amount_of_matched_text;
  1318. yy_current_state = yy_get_previous_state( );
  1319. yy_cp = (yy_c_buf_p);
  1320. yy_bp = (yytext_ptr) + YY_MORE_ADJ;
  1321. goto yy_match;
  1322. case EOB_ACT_LAST_MATCH:
  1323. (yy_c_buf_p) =
  1324. &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
  1325. yy_current_state = yy_get_previous_state( );
  1326. yy_cp = (yy_c_buf_p);
  1327. yy_bp = (yytext_ptr) + YY_MORE_ADJ;
  1328. goto yy_find_action;
  1329. }
  1330. break;
  1331. }
  1332. default:
  1333. YY_FATAL_ERROR(
  1334. "fatal flex scanner internal error--no action found" );
  1335. } /* end of action switch */
  1336. } /* end of scanning one token */
  1337. } /* end of user's declarations */
  1338. } /* end of yylex */
  1339. /* %ok-for-header */
  1340. /* %if-c++-only */
  1341. /* %not-for-header */
  1342. /* %ok-for-header */
  1343. /* %endif */
  1344. /* yy_get_next_buffer - try to read in a new buffer
  1345. *
  1346. * Returns a code representing an action:
  1347. * EOB_ACT_LAST_MATCH -
  1348. * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
  1349. * EOB_ACT_END_OF_FILE - end of file
  1350. */
  1351. /* %if-c-only */
  1352. static int yy_get_next_buffer (void)
  1353. /* %endif */
  1354. /* %if-c++-only */
  1355. /* %endif */
  1356. {
  1357. char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
  1358. char *source = (yytext_ptr);
  1359. int number_to_move, i;
  1360. int ret_val;
  1361. if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
  1362. YY_FATAL_ERROR(
  1363. "fatal flex scanner internal error--end of buffer missed" );
  1364. if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
  1365. { /* Don't try to fill the buffer, so this is an EOF. */
  1366. if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
  1367. {
  1368. /* We matched a single character, the EOB, so
  1369. * treat this as a final EOF.
  1370. */
  1371. return EOB_ACT_END_OF_FILE;
  1372. }
  1373. else
  1374. {
  1375. /* We matched some text prior to the EOB, first
  1376. * process it.
  1377. */
  1378. return EOB_ACT_LAST_MATCH;
  1379. }
  1380. }
  1381. /* Try to read more data. */
  1382. /* First move last chars to start of buffer. */
  1383. number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1);
  1384. for ( i = 0; i < number_to_move; ++i )
  1385. *(dest++) = *(source++);
  1386. if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
  1387. /* don't do the read, it's not guaranteed to return an EOF,
  1388. * just force an EOF
  1389. */
  1390. YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
  1391. else
  1392. {
  1393. int num_to_read =
  1394. YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
  1395. while ( num_to_read <= 0 )
  1396. { /* Not enough room in the buffer - grow it. */
  1397. /* just a shorter name for the current buffer */
  1398. YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
  1399. int yy_c_buf_p_offset =
  1400. (int) ((yy_c_buf_p) - b->yy_ch_buf);
  1401. if ( b->yy_is_our_buffer )
  1402. {
  1403. int new_size = b->yy_buf_size * 2;
  1404. if ( new_size <= 0 )
  1405. b->yy_buf_size += b->yy_buf_size / 8;
  1406. else
  1407. b->yy_buf_size *= 2;
  1408. b->yy_ch_buf = (char *)
  1409. /* Include room in for 2 EOB chars. */
  1410. yyrealloc( (void *) b->yy_ch_buf,
  1411. (yy_size_t) (b->yy_buf_size + 2) );
  1412. }
  1413. else
  1414. /* Can't grow it, we don't own it. */
  1415. b->yy_ch_buf = NULL;
  1416. if ( ! b->yy_ch_buf )
  1417. YY_FATAL_ERROR(
  1418. "fatal error - scanner input buffer overflow" );
  1419. (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
  1420. num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
  1421. number_to_move - 1;
  1422. }
  1423. if ( num_to_read > YY_READ_BUF_SIZE )
  1424. num_to_read = YY_READ_BUF_SIZE;
  1425. /* Read in more data. */
  1426. YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
  1427. (yy_n_chars), num_to_read );
  1428. YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
  1429. }
  1430. if ( (yy_n_chars) == 0 )
  1431. {
  1432. if ( number_to_move == YY_MORE_ADJ )
  1433. {
  1434. ret_val = EOB_ACT_END_OF_FILE;
  1435. yyrestart( yyin );
  1436. }
  1437. else
  1438. {
  1439. ret_val = EOB_ACT_LAST_MATCH;
  1440. YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
  1441. YY_BUFFER_EOF_PENDING;
  1442. }
  1443. }
  1444. else
  1445. ret_val = EOB_ACT_CONTINUE_SCAN;
  1446. if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
  1447. /* Extend the array by 50%, plus the number we really need. */
  1448. int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
  1449. YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
  1450. (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size );
  1451. if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
  1452. YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
  1453. /* "- 2" to take care of EOB's */
  1454. YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2);
  1455. }
  1456. (yy_n_chars) += number_to_move;
  1457. YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
  1458. YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
  1459. (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
  1460. return ret_val;
  1461. }
  1462. /* yy_get_previous_state - get the state just before the EOB char was reached */
  1463. /* %if-c-only */
  1464. /* %not-for-header */
  1465. static yy_state_type yy_get_previous_state (void)
  1466. /* %endif */
  1467. /* %if-c++-only */
  1468. /* %endif */
  1469. {
  1470. yy_state_type yy_current_state;
  1471. char *yy_cp;
  1472. /* %% [15.0] code to get the start state into yy_current_state goes here */
  1473. yy_current_state = (yy_start);
  1474. for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
  1475. {
  1476. /* %% [16.0] code to find the next state goes here */
  1477. YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 18);
  1478. if ( yy_accept[yy_current_state] )
  1479. {
  1480. (yy_last_accepting_state) = yy_current_state;
  1481. (yy_last_accepting_cpos) = yy_cp;
  1482. }
  1483. while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  1484. {
  1485. yy_current_state = (int) yy_def[yy_current_state];
  1486. if ( yy_current_state >= 82 )
  1487. yy_c = yy_meta[yy_c];
  1488. }
  1489. yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
  1490. }
  1491. return yy_current_state;
  1492. }
  1493. /* yy_try_NUL_trans - try to make a transition on the NUL character
  1494. *
  1495. * synopsis
  1496. * next_state = yy_try_NUL_trans( current_state );
  1497. */
  1498. /* %if-c-only */
  1499. static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
  1500. /* %endif */
  1501. /* %if-c++-only */
  1502. /* %endif */
  1503. {
  1504. int yy_is_jam;
  1505. /* %% [17.0] code to find the next state, and perhaps do backing up, goes here */
  1506. char *yy_cp = (yy_c_buf_p);
  1507. YY_CHAR yy_c = 18;
  1508. if ( yy_accept[yy_current_state] )
  1509. {
  1510. (yy_last_accepting_state) = yy_current_state;
  1511. (yy_last_accepting_cpos) = yy_cp;
  1512. }
  1513. while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  1514. {
  1515. yy_current_state = (int) yy_def[yy_current_state];
  1516. if ( yy_current_state >= 82 )
  1517. yy_c = yy_meta[yy_c];
  1518. }
  1519. yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
  1520. yy_is_jam = (yy_current_state == 81);
  1521. return yy_is_jam ? 0 : yy_current_state;
  1522. }
  1523. #ifndef YY_NO_UNPUT
  1524. /* %if-c-only */
  1525. /* %endif */
  1526. #endif
  1527. /* %if-c-only */
  1528. #ifndef YY_NO_INPUT
  1529. #ifdef __cplusplus
  1530. static int yyinput (void)
  1531. #else
  1532. static int input (void)
  1533. #endif
  1534. /* %endif */
  1535. /* %if-c++-only */
  1536. /* %endif */
  1537. {
  1538. int c;
  1539. *(yy_c_buf_p) = (yy_hold_char);
  1540. if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
  1541. {
  1542. /* yy_c_buf_p now points to the character we want to return.
  1543. * If this occurs *before* the EOB characters, then it's a
  1544. * valid NUL; if not, then we've hit the end of the buffer.
  1545. */
  1546. if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
  1547. /* This was really a NUL. */
  1548. *(yy_c_buf_p) = '\0';
  1549. else
  1550. { /* need more input */
  1551. int offset = (int) ((yy_c_buf_p) - (yytext_ptr));
  1552. ++(yy_c_buf_p);
  1553. switch ( yy_get_next_buffer( ) )
  1554. {
  1555. case EOB_ACT_LAST_MATCH:
  1556. /* This happens because yy_g_n_b()
  1557. * sees that we've accumulated a
  1558. * token and flags that we need to
  1559. * try matching the token before
  1560. * proceeding. But for input(),
  1561. * there's no matching to consider.
  1562. * So convert the EOB_ACT_LAST_MATCH
  1563. * to EOB_ACT_END_OF_FILE.
  1564. */
  1565. /* Reset buffer status. */
  1566. yyrestart( yyin );
  1567. /*FALLTHROUGH*/
  1568. case EOB_ACT_END_OF_FILE:
  1569. {
  1570. if ( yywrap( ) )
  1571. return 0;
  1572. if ( ! (yy_did_buffer_switch_on_eof) )
  1573. YY_NEW_FILE;
  1574. #ifdef __cplusplus
  1575. return yyinput();
  1576. #else
  1577. return input();
  1578. #endif
  1579. }
  1580. case EOB_ACT_CONTINUE_SCAN:
  1581. (yy_c_buf_p) = (yytext_ptr) + offset;
  1582. break;
  1583. }
  1584. }
  1585. }
  1586. c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
  1587. *(yy_c_buf_p) = '\0'; /* preserve yytext */
  1588. (yy_hold_char) = *++(yy_c_buf_p);
  1589. /* %% [19.0] update BOL and yylineno */
  1590. return c;
  1591. }
  1592. /* %if-c-only */
  1593. #endif /* ifndef YY_NO_INPUT */
  1594. /* %endif */
  1595. /** Immediately switch to a different input stream.
  1596. * @param input_file A readable stream.
  1597. *
  1598. * @note This function does not reset the start condition to @c INITIAL .
  1599. */
  1600. /* %if-c-only */
  1601. void yyrestart (FILE * input_file )
  1602. /* %endif */
  1603. /* %if-c++-only */
  1604. /* %endif */
  1605. {
  1606. if ( ! YY_CURRENT_BUFFER ){
  1607. yyensure_buffer_stack ();
  1608. YY_CURRENT_BUFFER_LVALUE =
  1609. yy_create_buffer( yyin, YY_BUF_SIZE );
  1610. }
  1611. yy_init_buffer( YY_CURRENT_BUFFER, input_file );
  1612. yy_load_buffer_state( );
  1613. }
  1614. /* %if-c++-only */
  1615. /* %endif */
  1616. /** Switch to a different input buffer.
  1617. * @param new_buffer The new input buffer.
  1618. *
  1619. */
  1620. /* %if-c-only */
  1621. void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer )
  1622. /* %endif */
  1623. /* %if-c++-only */
  1624. /* %endif */
  1625. {
  1626. /* TODO. We should be able to replace this entire function body
  1627. * with
  1628. * yypop_buffer_state();
  1629. * yypush_buffer_state(new_buffer);
  1630. */
  1631. yyensure_buffer_stack ();
  1632. if ( YY_CURRENT_BUFFER == new_buffer )
  1633. return;
  1634. if ( YY_CURRENT_BUFFER )
  1635. {
  1636. /* Flush out information for old buffer. */
  1637. *(yy_c_buf_p) = (yy_hold_char);
  1638. YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
  1639. YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
  1640. }
  1641. YY_CURRENT_BUFFER_LVALUE = new_buffer;
  1642. yy_load_buffer_state( );
  1643. /* We don't actually know whether we did this switch during
  1644. * EOF (yywrap()) processing, but the only time this flag
  1645. * is looked at is after yywrap() is called, so it's safe
  1646. * to go ahead and always set it.
  1647. */
  1648. (yy_did_buffer_switch_on_eof) = 1;
  1649. }
  1650. /* %if-c-only */
  1651. static void yy_load_buffer_state (void)
  1652. /* %endif */
  1653. /* %if-c++-only */
  1654. /* %endif */
  1655. {
  1656. (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
  1657. (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
  1658. /* %if-c-only */
  1659. yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
  1660. /* %endif */
  1661. /* %if-c++-only */
  1662. /* %endif */
  1663. (yy_hold_char) = *(yy_c_buf_p);
  1664. }
  1665. /** Allocate and initialize an input buffer state.
  1666. * @param file A readable stream.
  1667. * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
  1668. *
  1669. * @return the allocated buffer state.
  1670. */
  1671. /* %if-c-only */
  1672. YY_BUFFER_STATE yy_create_buffer (FILE * file, int size )
  1673. /* %endif */
  1674. /* %if-c++-only */
  1675. /* %endif */
  1676. {
  1677. YY_BUFFER_STATE b;
  1678. b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) );
  1679. if ( ! b )
  1680. YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
  1681. b->yy_buf_size = size;
  1682. /* yy_ch_buf has to be 2 characters longer than the size given because
  1683. * we need to put in 2 end-of-buffer characters.
  1684. */
  1685. b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) );
  1686. if ( ! b->yy_ch_buf )
  1687. YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
  1688. b->yy_is_our_buffer = 1;
  1689. yy_init_buffer( b, file );
  1690. return b;
  1691. }
  1692. /* %if-c++-only */
  1693. /* %endif */
  1694. /** Destroy the buffer.
  1695. * @param b a buffer created with yy_create_buffer()
  1696. *
  1697. */
  1698. /* %if-c-only */
  1699. void yy_delete_buffer (YY_BUFFER_STATE b )
  1700. /* %endif */
  1701. /* %if-c++-only */
  1702. /* %endif */
  1703. {
  1704. if ( ! b )
  1705. return;
  1706. if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
  1707. YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
  1708. if ( b->yy_is_our_buffer )
  1709. yyfree( (void *) b->yy_ch_buf );
  1710. yyfree( (void *) b );
  1711. }
  1712. /* Initializes or reinitializes a buffer.
  1713. * This function is sometimes called more than once on the same buffer,
  1714. * such as during a yyrestart() or at EOF.
  1715. */
  1716. /* %if-c-only */
  1717. static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file )
  1718. /* %endif */
  1719. /* %if-c++-only */
  1720. /* %endif */
  1721. {
  1722. int oerrno = errno;
  1723. yy_flush_buffer( b );
  1724. /* %if-c-only */
  1725. b->yy_input_file = file;
  1726. /* %endif */
  1727. /* %if-c++-only */
  1728. /* %endif */
  1729. b->yy_fill_buffer = 1;
  1730. /* If b is the current buffer, then yy_init_buffer was _probably_
  1731. * called from yyrestart() or through yy_get_next_buffer.
  1732. * In that case, we don't want to reset the lineno or column.
  1733. */
  1734. if (b != YY_CURRENT_BUFFER){
  1735. b->yy_bs_lineno = 1;
  1736. b->yy_bs_column = 0;
  1737. }
  1738. /* %if-c-only */
  1739. b->yy_is_interactive = 0;
  1740. /* %endif */
  1741. /* %if-c++-only */
  1742. /* %endif */
  1743. errno = oerrno;
  1744. }
  1745. /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
  1746. * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
  1747. *
  1748. */
  1749. /* %if-c-only */
  1750. void yy_flush_buffer (YY_BUFFER_STATE b )
  1751. /* %endif */
  1752. /* %if-c++-only */
  1753. /* %endif */
  1754. {
  1755. if ( ! b )
  1756. return;
  1757. b->yy_n_chars = 0;
  1758. /* We always need two end-of-buffer characters. The first causes
  1759. * a transition to the end-of-buffer state. The second causes
  1760. * a jam in that state.
  1761. */
  1762. b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
  1763. b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
  1764. b->yy_buf_pos = &b->yy_ch_buf[0];
  1765. b->yy_at_bol = 1;
  1766. b->yy_buffer_status = YY_BUFFER_NEW;
  1767. if ( b == YY_CURRENT_BUFFER )
  1768. yy_load_buffer_state( );
  1769. }
  1770. /* %if-c-or-c++ */
  1771. /** Pushes the new state onto the stack. The new state becomes
  1772. * the current state. This function will allocate the stack
  1773. * if necessary.
  1774. * @param new_buffer The new state.
  1775. *
  1776. */
  1777. /* %if-c-only */
  1778. void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
  1779. /* %endif */
  1780. /* %if-c++-only */
  1781. /* %endif */
  1782. {
  1783. if (new_buffer == NULL)
  1784. return;
  1785. yyensure_buffer_stack();
  1786. /* This block is copied from yy_switch_to_buffer. */
  1787. if ( YY_CURRENT_BUFFER )
  1788. {
  1789. /* Flush out information for old buffer. */
  1790. *(yy_c_buf_p) = (yy_hold_char);
  1791. YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
  1792. YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
  1793. }
  1794. /* Only push if top exists. Otherwise, replace top. */
  1795. if (YY_CURRENT_BUFFER)
  1796. (yy_buffer_stack_top)++;
  1797. YY_CURRENT_BUFFER_LVALUE = new_buffer;
  1798. /* copied from yy_switch_to_buffer. */
  1799. yy_load_buffer_state( );
  1800. (yy_did_buffer_switch_on_eof) = 1;
  1801. }
  1802. /* %endif */
  1803. /* %if-c-or-c++ */
  1804. /** Removes and deletes the top of the stack, if present.
  1805. * The next element becomes the new top.
  1806. *
  1807. */
  1808. /* %if-c-only */
  1809. void yypop_buffer_state (void)
  1810. /* %endif */
  1811. /* %if-c++-only */
  1812. /* %endif */
  1813. {
  1814. if (!YY_CURRENT_BUFFER)
  1815. return;
  1816. yy_delete_buffer(YY_CURRENT_BUFFER );
  1817. YY_CURRENT_BUFFER_LVALUE = NULL;
  1818. if ((yy_buffer_stack_top) > 0)
  1819. --(yy_buffer_stack_top);
  1820. if (YY_CURRENT_BUFFER) {
  1821. yy_load_buffer_state( );
  1822. (yy_did_buffer_switch_on_eof) = 1;
  1823. }
  1824. }
  1825. /* %endif */
  1826. /* %if-c-or-c++ */
  1827. /* Allocates the stack if it does not exist.
  1828. * Guarantees space for at least one push.
  1829. */
  1830. /* %if-c-only */
  1831. static void yyensure_buffer_stack (void)
  1832. /* %endif */
  1833. /* %if-c++-only */
  1834. /* %endif */
  1835. {
  1836. yy_size_t num_to_alloc;
  1837. if (!(yy_buffer_stack)) {
  1838. /* First allocation is just for 2 elements, since we don't know if this
  1839. * scanner will even need a stack. We use 2 instead of 1 to avoid an
  1840. * immediate realloc on the next call.
  1841. */
  1842. num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
  1843. (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
  1844. (num_to_alloc * sizeof(struct yy_buffer_state*)
  1845. );
  1846. if ( ! (yy_buffer_stack) )
  1847. YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
  1848. memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
  1849. (yy_buffer_stack_max) = num_to_alloc;
  1850. (yy_buffer_stack_top) = 0;
  1851. return;
  1852. }
  1853. if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
  1854. /* Increase the buffer to prepare for a possible push. */
  1855. yy_size_t grow_size = 8 /* arbitrary grow size */;
  1856. num_to_alloc = (yy_buffer_stack_max) + grow_size;
  1857. (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
  1858. ((yy_buffer_stack),
  1859. num_to_alloc * sizeof(struct yy_buffer_state*)
  1860. );
  1861. if ( ! (yy_buffer_stack) )
  1862. YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
  1863. /* zero only the new slots.*/
  1864. memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
  1865. (yy_buffer_stack_max) = num_to_alloc;
  1866. }
  1867. }
  1868. /* %endif */
  1869. /* %if-c-only */
  1870. /** Setup the input buffer state to scan directly from a user-specified character buffer.
  1871. * @param base the character buffer
  1872. * @param size the size in bytes of the character buffer
  1873. *
  1874. * @return the newly allocated buffer state object.
  1875. */
  1876. YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
  1877. {
  1878. YY_BUFFER_STATE b;
  1879. if ( size < 2 ||
  1880. base[size-2] != YY_END_OF_BUFFER_CHAR ||
  1881. base[size-1] != YY_END_OF_BUFFER_CHAR )
  1882. /* They forgot to leave room for the EOB's. */
  1883. return NULL;
  1884. b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) );
  1885. if ( ! b )
  1886. YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
  1887. b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */
  1888. b->yy_buf_pos = b->yy_ch_buf = base;
  1889. b->yy_is_our_buffer = 0;
  1890. b->yy_input_file = NULL;
  1891. b->yy_n_chars = b->yy_buf_size;
  1892. b->yy_is_interactive = 0;
  1893. b->yy_at_bol = 1;
  1894. b->yy_fill_buffer = 0;
  1895. b->yy_buffer_status = YY_BUFFER_NEW;
  1896. yy_switch_to_buffer( b );
  1897. return b;
  1898. }
  1899. /* %endif */
  1900. /* %if-c-only */
  1901. /** Setup the input buffer state to scan a string. The next call to yylex() will
  1902. * scan from a @e copy of @a str.
  1903. * @param yystr a NUL-terminated string to scan
  1904. *
  1905. * @return the newly allocated buffer state object.
  1906. * @note If you want to scan bytes that may contain NUL values, then use
  1907. * yy_scan_bytes() instead.
  1908. */
  1909. YY_BUFFER_STATE yy_scan_string (const char * yystr )
  1910. {
  1911. return yy_scan_bytes( yystr, (int) strlen(yystr) );
  1912. }
  1913. /* %endif */
  1914. /* %if-c-only */
  1915. /** Setup the input buffer state to scan the given bytes. The next call to yylex() will
  1916. * scan from a @e copy of @a bytes.
  1917. * @param yybytes the byte buffer to scan
  1918. * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
  1919. *
  1920. * @return the newly allocated buffer state object.
  1921. */
  1922. YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len )
  1923. {
  1924. YY_BUFFER_STATE b;
  1925. char *buf;
  1926. yy_size_t n;
  1927. int i;
  1928. /* Get memory for full buffer, including space for trailing EOB's. */
  1929. n = (yy_size_t) (_yybytes_len + 2);
  1930. buf = (char *) yyalloc( n );
  1931. if ( ! buf )
  1932. YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
  1933. for ( i = 0; i < _yybytes_len; ++i )
  1934. buf[i] = yybytes[i];
  1935. buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
  1936. b = yy_scan_buffer( buf, n );
  1937. if ( ! b )
  1938. YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
  1939. /* It's okay to grow etc. this buffer, and we should throw it
  1940. * away when we're done.
  1941. */
  1942. b->yy_is_our_buffer = 1;
  1943. return b;
  1944. }
  1945. /* %endif */
  1946. #ifndef YY_EXIT_FAILURE
  1947. #define YY_EXIT_FAILURE 2
  1948. #endif
  1949. /* %if-c-only */
  1950. static void yynoreturn yy_fatal_error (const char* msg )
  1951. {
  1952. fprintf( stderr, "%s\n", msg );
  1953. exit( YY_EXIT_FAILURE );
  1954. }
  1955. /* %endif */
  1956. /* %if-c++-only */
  1957. /* %endif */
  1958. /* Redefine yyless() so it works in section 3 code. */
  1959. #undef yyless
  1960. #define yyless(n) \
  1961. do \
  1962. { \
  1963. /* Undo effects of setting up yytext. */ \
  1964. int yyless_macro_arg = (n); \
  1965. YY_LESS_LINENO(yyless_macro_arg);\
  1966. yytext[yyleng] = (yy_hold_char); \
  1967. (yy_c_buf_p) = yytext + yyless_macro_arg; \
  1968. (yy_hold_char) = *(yy_c_buf_p); \
  1969. *(yy_c_buf_p) = '\0'; \
  1970. yyleng = yyless_macro_arg; \
  1971. } \
  1972. while ( 0 )
  1973. /* Accessor methods (get/set functions) to struct members. */
  1974. /* %if-c-only */
  1975. /* %if-reentrant */
  1976. /* %endif */
  1977. /** Get the current line number.
  1978. *
  1979. */
  1980. int yyget_lineno (void)
  1981. {
  1982. return yylineno;
  1983. }
  1984. /** Get the input stream.
  1985. *
  1986. */
  1987. FILE *yyget_in (void)
  1988. {
  1989. return yyin;
  1990. }
  1991. /** Get the output stream.
  1992. *
  1993. */
  1994. FILE *yyget_out (void)
  1995. {
  1996. return yyout;
  1997. }
  1998. /** Get the length of the current token.
  1999. *
  2000. */
  2001. int yyget_leng (void)
  2002. {
  2003. return yyleng;
  2004. }
  2005. /** Get the current token.
  2006. *
  2007. */
  2008. char *yyget_text (void)
  2009. {
  2010. return yytext;
  2011. }
  2012. /* %if-reentrant */
  2013. /* %endif */
  2014. /** Set the current line number.
  2015. * @param _line_number line number
  2016. *
  2017. */
  2018. void yyset_lineno (int _line_number )
  2019. {
  2020. yylineno = _line_number;
  2021. }
  2022. /** Set the input stream. This does not discard the current
  2023. * input buffer.
  2024. * @param _in_str A readable stream.
  2025. *
  2026. * @see yy_switch_to_buffer
  2027. */
  2028. void yyset_in (FILE * _in_str )
  2029. {
  2030. yyin = _in_str ;
  2031. }
  2032. void yyset_out (FILE * _out_str )
  2033. {
  2034. yyout = _out_str ;
  2035. }
  2036. int yyget_debug (void)
  2037. {
  2038. return yy_flex_debug;
  2039. }
  2040. void yyset_debug (int _bdebug )
  2041. {
  2042. yy_flex_debug = _bdebug ;
  2043. }
  2044. /* %endif */
  2045. /* %if-reentrant */
  2046. /* %if-bison-bridge */
  2047. /* %endif */
  2048. /* %endif if-c-only */
  2049. /* %if-c-only */
  2050. static int yy_init_globals (void)
  2051. {
  2052. /* Initialization is the same as for the non-reentrant scanner.
  2053. * This function is called from yylex_destroy(), so don't allocate here.
  2054. */
  2055. (yy_buffer_stack) = NULL;
  2056. (yy_buffer_stack_top) = 0;
  2057. (yy_buffer_stack_max) = 0;
  2058. (yy_c_buf_p) = NULL;
  2059. (yy_init) = 0;
  2060. (yy_start) = 0;
  2061. /* Defined in main.c */
  2062. #ifdef YY_STDINIT
  2063. yyin = stdin;
  2064. yyout = stdout;
  2065. #else
  2066. yyin = NULL;
  2067. yyout = NULL;
  2068. #endif
  2069. /* For future reference: Set errno on error, since we are called by
  2070. * yylex_init()
  2071. */
  2072. return 0;
  2073. }
  2074. /* %endif */
  2075. /* %if-c-only SNIP! this currently causes conflicts with the c++ scanner */
  2076. /* yylex_destroy is for both reentrant and non-reentrant scanners. */
  2077. int yylex_destroy (void)
  2078. {
  2079. /* Pop the buffer stack, destroying each element. */
  2080. while(YY_CURRENT_BUFFER){
  2081. yy_delete_buffer( YY_CURRENT_BUFFER );
  2082. YY_CURRENT_BUFFER_LVALUE = NULL;
  2083. yypop_buffer_state();
  2084. }
  2085. /* Destroy the stack itself. */
  2086. yyfree((yy_buffer_stack) );
  2087. (yy_buffer_stack) = NULL;
  2088. /* Reset the globals. This is important in a non-reentrant scanner so the next time
  2089. * yylex() is called, initialization will occur. */
  2090. yy_init_globals( );
  2091. /* %if-reentrant */
  2092. /* %endif */
  2093. return 0;
  2094. }
  2095. /* %endif */
  2096. /*
  2097. * Internal utility routines.
  2098. */
  2099. #ifndef yytext_ptr
  2100. static void yy_flex_strncpy (char* s1, const char * s2, int n )
  2101. {
  2102. int i;
  2103. for ( i = 0; i < n; ++i )
  2104. s1[i] = s2[i];
  2105. }
  2106. #endif
  2107. #ifdef YY_NEED_STRLEN
  2108. static int yy_flex_strlen (const char * s )
  2109. {
  2110. int n;
  2111. for ( n = 0; s[n]; ++n )
  2112. ;
  2113. return n;
  2114. }
  2115. #endif
  2116. void *yyalloc (yy_size_t size )
  2117. {
  2118. return malloc(size);
  2119. }
  2120. void *yyrealloc (void * ptr, yy_size_t size )
  2121. {
  2122. /* The cast to (char *) in the following accommodates both
  2123. * implementations that use char* generic pointers, and those
  2124. * that use void* generic pointers. It works with the latter
  2125. * because both ANSI C and C++ allow castless assignment from
  2126. * any pointer type to void*, and deal with argument conversions
  2127. * as though doing an assignment.
  2128. */
  2129. return realloc(ptr, size);
  2130. }
  2131. void yyfree (void * ptr )
  2132. {
  2133. free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
  2134. }
  2135. /* %if-tables-serialization definitions */
  2136. /* %define-yytables The name for this specific scanner's tables. */
  2137. #define YYTABLES_NAME "yytables"
  2138. /* %endif */
  2139. /* %ok-for-header */
  2140. #line 209 "/Users/akim/src/gnu/bison/src/scan-code.l"
  2141. static inline bool
  2142. is_dot_or_dash (char ch)
  2143. {
  2144. return ch == '.' || ch == '-';
  2145. }
  2146. static inline bool
  2147. contains_dot_or_dash (const char* p)
  2148. {
  2149. return !!strpbrk (p, ".-");
  2150. }
  2151. /* Defines a variant of a symbolic name resolution. */
  2152. typedef struct
  2153. {
  2154. /* Index in symbol list. */
  2155. int symbol_index;
  2156. /* Matched symbol id and loc. */
  2157. uniqstr id;
  2158. location loc;
  2159. /* Hiding named reference. */
  2160. named_ref* hidden_by;
  2161. /* Error flags. May contain zero (no errors) or
  2162. a combination of VARIANT_* values. */
  2163. unsigned err;
  2164. } variant;
  2165. /* Set when the variant refers to a symbol hidden
  2166. by an explicit symbol reference. */
  2167. #define VARIANT_HIDDEN (1 << 0)
  2168. /* Set when the variant refers to a symbol containing
  2169. dots or dashes. Will require explicit bracketing. */
  2170. #define VARIANT_BAD_BRACKETING (1 << 1)
  2171. /* Set when the variant refers to a symbol which is
  2172. not visible from current midrule. */
  2173. #define VARIANT_NOT_VISIBLE_FROM_MIDRULE (1 << 2)
  2174. static variant *variant_table = NULL;
  2175. static int variant_table_size = 0;
  2176. static int variant_count = 0;
  2177. static variant *
  2178. variant_table_grow (void)
  2179. {
  2180. ++variant_count;
  2181. if (variant_count > variant_table_size)
  2182. {
  2183. while (variant_count > variant_table_size)
  2184. variant_table_size = 2 * variant_table_size + 3;
  2185. variant_table = xnrealloc (variant_table, variant_table_size,
  2186. sizeof *variant_table);
  2187. }
  2188. return &variant_table[variant_count - 1];
  2189. }
  2190. static void
  2191. variant_table_free (void)
  2192. {
  2193. free (variant_table);
  2194. variant_table = NULL;
  2195. variant_table_size = variant_count = 0;
  2196. }
  2197. static char const *
  2198. find_prefix_end (char const *prefix, char const *cp, char const *end)
  2199. {
  2200. for (; *prefix && cp != end; ++prefix, ++cp)
  2201. if (*prefix != *cp)
  2202. return NULL;
  2203. return *prefix ? NULL : cp;
  2204. }
  2205. static variant *
  2206. variant_add (uniqstr id, location id_loc, int symbol_index,
  2207. char const *cp, char const *cp_end, bool explicit_bracketing)
  2208. {
  2209. char const *prefix_end = find_prefix_end (id, cp, cp_end);
  2210. if (prefix_end &&
  2211. (prefix_end == cp_end ||
  2212. (!explicit_bracketing && is_dot_or_dash (*prefix_end))))
  2213. {
  2214. variant *r = variant_table_grow ();
  2215. r->symbol_index = symbol_index;
  2216. r->id = id;
  2217. r->loc = id_loc;
  2218. r->hidden_by = NULL;
  2219. r->err = 0;
  2220. return r;
  2221. }
  2222. else
  2223. return NULL;
  2224. }
  2225. static const char *
  2226. get_at_spec(int symbol_index)
  2227. {
  2228. static char at_buf[20];
  2229. if (symbol_index == 0)
  2230. strcpy (at_buf, "$$");
  2231. else
  2232. snprintf (at_buf, sizeof at_buf, "$%u", symbol_index);
  2233. return at_buf;
  2234. }
  2235. static void
  2236. show_sub_message (warnings warning,
  2237. const char* cp, bool explicit_bracketing,
  2238. int midrule_rhs_index, char dollar_or_at,
  2239. const variant *var)
  2240. {
  2241. const char *at_spec = get_at_spec (var->symbol_index);
  2242. if (var->err == 0)
  2243. subcomplain (&var->loc, warning,
  2244. _("refers to: %c%s at %s"), dollar_or_at,
  2245. var->id, at_spec);
  2246. else
  2247. {
  2248. const char *id;
  2249. location id_loc;
  2250. if (var->hidden_by)
  2251. {
  2252. id = var->hidden_by->id;
  2253. id_loc = var->hidden_by->loc;
  2254. }
  2255. else
  2256. {
  2257. id = var->id;
  2258. id_loc = var->loc;
  2259. }
  2260. const char *tail = explicit_bracketing ? "" : cp + strlen (var->id);
  2261. /* Create the explanation message. */
  2262. static struct obstack msg_buf;
  2263. obstack_init (&msg_buf);
  2264. obstack_printf (&msg_buf, _("possibly meant: %c"), dollar_or_at);
  2265. if (contains_dot_or_dash (id))
  2266. obstack_printf (&msg_buf, "[%s]", id);
  2267. else
  2268. obstack_sgrow (&msg_buf, id);
  2269. obstack_sgrow (&msg_buf, tail);
  2270. if (var->err & VARIANT_HIDDEN)
  2271. {
  2272. obstack_printf (&msg_buf, _(", hiding %c"), dollar_or_at);
  2273. if (contains_dot_or_dash (var->id))
  2274. obstack_printf (&msg_buf, "[%s]", var->id);
  2275. else
  2276. obstack_sgrow (&msg_buf, var->id);
  2277. obstack_sgrow (&msg_buf, tail);
  2278. }
  2279. obstack_printf (&msg_buf, _(" at %s"), at_spec);
  2280. if (var->err & VARIANT_NOT_VISIBLE_FROM_MIDRULE)
  2281. obstack_printf (&msg_buf,
  2282. _(", cannot be accessed from midrule action at $%d"),
  2283. midrule_rhs_index);
  2284. subcomplain (&id_loc, warning, "%s",
  2285. obstack_finish0 (&msg_buf));
  2286. obstack_free (&msg_buf, 0);
  2287. }
  2288. }
  2289. static void
  2290. show_sub_messages (warnings warning,
  2291. const char* cp, bool explicit_bracketing,
  2292. int midrule_rhs_index, char dollar_or_at)
  2293. {
  2294. for (int i = 0; i < variant_count; ++i)
  2295. show_sub_message (warning | silent,
  2296. cp, explicit_bracketing,
  2297. midrule_rhs_index, dollar_or_at,
  2298. &variant_table[i]);
  2299. }
  2300. /* Returned from "parse_ref" when the reference
  2301. is inappropriate. */
  2302. #define INVALID_REF (INT_MIN)
  2303. /* Returned from "parse_ref" when the reference
  2304. points to LHS ($$) of the current rule or midrule. */
  2305. #define LHS_REF (INT_MIN + 1)
  2306. /* Parse named or positional reference. In case of positional
  2307. references, can return negative values for $-n "deep" stack
  2308. accesses. */
  2309. static long
  2310. parse_ref (char *cp, symbol_list *rule, int rule_length,
  2311. int midrule_rhs_index, char *text, const location *text_loc,
  2312. char dollar_or_at)
  2313. {
  2314. if ('$' == *cp)
  2315. return LHS_REF;
  2316. if (c_isdigit (*cp) || (*cp == '-' && c_isdigit (* (cp + 1))))
  2317. {
  2318. long num = strtol (cp, &cp, 10);
  2319. if (1 - INT_MAX + rule_length <= num && num <= rule_length)
  2320. return num;
  2321. else
  2322. {
  2323. complain (text_loc, complaint, _("integer out of range: %s"),
  2324. quote (text));
  2325. return INVALID_REF;
  2326. }
  2327. }
  2328. bool const explicit_bracketing = *cp == '[';
  2329. if (explicit_bracketing)
  2330. ++cp;
  2331. else
  2332. ref_tail_fields = strpbrk (cp, ".-");
  2333. char const *cp_end = strchr (cp, explicit_bracketing ? ']' : '\0');
  2334. /* Add all relevant variants. */
  2335. {
  2336. int symbol_index;
  2337. symbol_list *l;
  2338. variant_count = 0;
  2339. for (symbol_index = 0, l = rule; !symbol_list_null (l);
  2340. ++symbol_index, l = l->next)
  2341. {
  2342. if (l->content_type != SYMLIST_SYMBOL)
  2343. continue;
  2344. variant *var
  2345. = variant_add (l->content.sym->tag, l->sym_loc,
  2346. symbol_index, cp, cp_end, explicit_bracketing);
  2347. if (var && l->named_ref)
  2348. var->hidden_by = l->named_ref;
  2349. if (l->named_ref)
  2350. variant_add (l->named_ref->id, l->named_ref->loc,
  2351. symbol_index, cp, cp_end, explicit_bracketing);
  2352. }
  2353. }
  2354. /* Check errors. */
  2355. int valid_variants = 0;
  2356. int valid_variant_index = 0;
  2357. for (int i = 0; i < variant_count; ++i)
  2358. {
  2359. variant *var = &variant_table[i];
  2360. int symbol_index = var->symbol_index;
  2361. /* Check visibility from midrule actions. */
  2362. if (midrule_rhs_index != 0
  2363. && (symbol_index == 0 || midrule_rhs_index < symbol_index))
  2364. var->err |= VARIANT_NOT_VISIBLE_FROM_MIDRULE;
  2365. /* Check correct bracketing. */
  2366. if (!explicit_bracketing && contains_dot_or_dash (var->id))
  2367. var->err |= VARIANT_BAD_BRACKETING;
  2368. /* Check using of hidden symbols. */
  2369. if (var->hidden_by)
  2370. var->err |= VARIANT_HIDDEN;
  2371. if (!var->err)
  2372. {
  2373. valid_variant_index = i;
  2374. ++valid_variants;
  2375. }
  2376. }
  2377. switch (valid_variants)
  2378. {
  2379. case 0:
  2380. {
  2381. int len = (explicit_bracketing || !ref_tail_fields) ?
  2382. cp_end - cp : ref_tail_fields - cp;
  2383. complain (text_loc, complaint,
  2384. _("invalid reference: %s"), quote (text));
  2385. if (len == 0)
  2386. {
  2387. location sym_loc = *text_loc;
  2388. sym_loc.start.column += 1;
  2389. sym_loc.end = sym_loc.start;
  2390. subcomplain (&sym_loc, complaint,
  2391. _("syntax error after '%c', expecting integer, "
  2392. "letter, '_', '[', or '$'"),
  2393. dollar_or_at);
  2394. }
  2395. else if (midrule_rhs_index)
  2396. subcomplain (&rule->rhs_loc, complaint,
  2397. _("symbol not found in production before $%d: "
  2398. "%.*s"),
  2399. midrule_rhs_index, len, cp);
  2400. else
  2401. subcomplain (&rule->rhs_loc, complaint,
  2402. _("symbol not found in production: %.*s"),
  2403. len, cp);
  2404. if (variant_count > 0)
  2405. show_sub_messages (complaint,
  2406. cp, explicit_bracketing, midrule_rhs_index,
  2407. dollar_or_at);
  2408. return INVALID_REF;
  2409. }
  2410. case 1:
  2411. {
  2412. if (variant_count > 1)
  2413. {
  2414. complain (text_loc, Wother,
  2415. _("misleading reference: %s"), quote (text));
  2416. show_sub_messages (Wother,
  2417. cp, explicit_bracketing, midrule_rhs_index,
  2418. dollar_or_at);
  2419. }
  2420. {
  2421. int symbol_index =
  2422. variant_table[valid_variant_index].symbol_index;
  2423. return (symbol_index == midrule_rhs_index) ? LHS_REF : symbol_index;
  2424. }
  2425. }
  2426. case 2:
  2427. default:
  2428. {
  2429. complain (text_loc, complaint,
  2430. _("ambiguous reference: %s"), quote (text));
  2431. show_sub_messages (complaint,
  2432. cp, explicit_bracketing, midrule_rhs_index,
  2433. dollar_or_at);
  2434. return INVALID_REF;
  2435. }
  2436. }
  2437. }
  2438. /* Keeps track of the maximum number of semantic values to the left of
  2439. a handle (those referenced by $0, $-1, etc.) are required by the
  2440. semantic actions of this grammar. */
  2441. int max_left_semantic_context = 0;
  2442. /* If CP points to a typename (i.e., <.*?>), set TYPE_NAME to its
  2443. beginning (i.e., after the opening "<", and return the pointer
  2444. immediately after it. */
  2445. static
  2446. char *
  2447. fetch_type_name (char *cp, char const **type_name,
  2448. const location *dollar_loc)
  2449. {
  2450. if (*cp == '<')
  2451. {
  2452. *type_name = ++cp;
  2453. /* Series of non-'>' or "->". */
  2454. while (*cp != '>' || cp[-1] == '-')
  2455. ++cp;
  2456. /* The '>' symbol will be later replaced by '\0'. Original
  2457. 'text' is needed for error messages. */
  2458. ++cp;
  2459. if (untyped_var_seen)
  2460. complain (dollar_loc, complaint,
  2461. _("explicit type given in untyped grammar"));
  2462. tag_seen = true;
  2463. }
  2464. return cp;
  2465. }
  2466. /*------------------------------------------------------------------.
  2467. | TEXT is pointing to a wannabee semantic value (i.e., a '$'). |
  2468. | |
  2469. | Possible inputs: $[<TYPENAME>]($|integer) |
  2470. | |
  2471. | Output to OBSTACK_FOR_STRING a reference to this semantic value. |
  2472. `------------------------------------------------------------------*/
  2473. static void
  2474. handle_action_dollar (symbol_list *rule, char *text, const location *dollar_loc)
  2475. {
  2476. symbol_list *effective_rule;
  2477. int effective_rule_length;
  2478. if (rule->midrule_parent_rule)
  2479. {
  2480. effective_rule = rule->midrule_parent_rule;
  2481. effective_rule_length = rule->midrule_parent_rhs_index - 1;
  2482. }
  2483. else
  2484. {
  2485. effective_rule = rule;
  2486. effective_rule_length = symbol_list_length (rule->next);
  2487. }
  2488. /* The type name if explicit, otherwise left null. */
  2489. char const *type_name = NULL;
  2490. char *cp = fetch_type_name (text + 1, &type_name, dollar_loc);
  2491. int n = parse_ref (cp, effective_rule, effective_rule_length,
  2492. rule->midrule_parent_rhs_index, text, dollar_loc, '$');
  2493. /* End type_name. Don't do it earlier: parse_ref depends on TEXT. */
  2494. if (type_name)
  2495. cp[-1] = '\0';
  2496. switch (n)
  2497. {
  2498. case INVALID_REF:
  2499. break;
  2500. case LHS_REF:
  2501. {
  2502. symbol_list *sym = symbol_list_n_get (rule, 0);
  2503. if (!type_name
  2504. && !sym->content.sym->content->type_name)
  2505. {
  2506. if (union_seen || tag_seen)
  2507. {
  2508. if (rule->midrule_parent_rule)
  2509. complain (dollar_loc, complaint,
  2510. _("$$ for the midrule at $%d of %s"
  2511. " has no declared type"),
  2512. rule->midrule_parent_rhs_index,
  2513. quote (effective_rule->content.sym->tag));
  2514. else
  2515. complain (dollar_loc, complaint,
  2516. _("$$ of %s has no declared type"),
  2517. quote (rule->content.sym->tag));
  2518. }
  2519. else
  2520. untyped_var_seen = true;
  2521. }
  2522. obstack_printf (&obstack_for_string, "]b4_lhs_value(orig %d, ",
  2523. sym->content.sym->content->number);
  2524. obstack_quote (&obstack_for_string, type_name);
  2525. obstack_sgrow (&obstack_for_string, ")[");
  2526. rule->action_props.is_value_used = true;
  2527. }
  2528. break;
  2529. /* Reference to a RHS symbol. */
  2530. default:
  2531. {
  2532. if (max_left_semantic_context < 1 - n)
  2533. max_left_semantic_context = 1 - n;
  2534. symbol_list *sym = 0 < n ? symbol_list_n_get (effective_rule, n) : NULL;
  2535. if (!type_name
  2536. && (!sym || !sym->content.sym->content->type_name))
  2537. {
  2538. if (union_seen || tag_seen)
  2539. complain (dollar_loc, complaint,
  2540. _("$%s of %s has no declared type"), cp,
  2541. quote (effective_rule->content.sym->tag));
  2542. else
  2543. untyped_var_seen = true;
  2544. }
  2545. obstack_printf (&obstack_for_string,
  2546. "]b4_rhs_value(%d, %d, ",
  2547. effective_rule_length, n);
  2548. if (sym)
  2549. obstack_printf (&obstack_for_string, "%s%d, ",
  2550. sym->content.sym->content->class == nterm_sym ? "orig " : "",
  2551. sym->content.sym->content->number);
  2552. else
  2553. obstack_sgrow (&obstack_for_string, "[], ");
  2554. obstack_quote (&obstack_for_string, type_name);
  2555. obstack_sgrow (&obstack_for_string, ")[");
  2556. if (0 < n)
  2557. {
  2558. if (muscle_percent_define_ifdef ("api.value.automove")
  2559. && sym->action_props.is_value_used)
  2560. complain (dollar_loc, Wother,
  2561. _("multiple occurrences of $%d with api.value.automove"),
  2562. n);
  2563. sym->action_props.is_value_used = true;
  2564. }
  2565. }
  2566. break;
  2567. }
  2568. }
  2569. /*------------------------------------------------------.
  2570. | TEXT is a location token (i.e., a '@...'). Output to |
  2571. | OBSTACK_FOR_STRING a reference to this location. |
  2572. `------------------------------------------------------*/
  2573. static void
  2574. handle_action_at (symbol_list *rule, char *text, const location *at_loc)
  2575. {
  2576. symbol_list *effective_rule;
  2577. int effective_rule_length;
  2578. if (rule->midrule_parent_rule)
  2579. {
  2580. effective_rule = rule->midrule_parent_rule;
  2581. effective_rule_length = rule->midrule_parent_rhs_index - 1;
  2582. }
  2583. else
  2584. {
  2585. effective_rule = rule;
  2586. effective_rule_length = symbol_list_length (rule->next);
  2587. }
  2588. muscle_percent_define_ensure ("locations", *at_loc, true);
  2589. int n = parse_ref (text + 1, effective_rule, effective_rule_length,
  2590. rule->midrule_parent_rhs_index, text, at_loc, '@');
  2591. switch (n)
  2592. {
  2593. case INVALID_REF:
  2594. break;
  2595. case LHS_REF:
  2596. obstack_sgrow (&obstack_for_string, "]b4_lhs_location[");
  2597. break;
  2598. default:
  2599. obstack_printf (&obstack_for_string, "]b4_rhs_location(%d, %d)[",
  2600. effective_rule_length, n);
  2601. break;
  2602. }
  2603. }
  2604. /*-------------------------.
  2605. | Initialize the scanner. |
  2606. `-------------------------*/
  2607. /* Translate the '$...' and '@...' in \a self, in the context \a
  2608. sc_context (SC_RULE_ACTION, SC_SYMBOL_ACTION, INITIAL). */
  2609. static char const *
  2610. translate_action (code_props *self, int sc_context)
  2611. {
  2612. static bool initialized = false;
  2613. if (!initialized)
  2614. {
  2615. obstack_init (&obstack_for_string);
  2616. yy_flex_debug = 0;
  2617. initialized = true;
  2618. }
  2619. loc->start = loc->end = self->location.start;
  2620. yy_switch_to_buffer (yy_scan_string (self->code));
  2621. char *res = code_lex (self, sc_context);
  2622. yy_delete_buffer (YY_CURRENT_BUFFER);
  2623. return res;
  2624. }
  2625. /*------------------------------------------------------------------------.
  2626. | Implementation of the public interface as documented in "scan-code.h". |
  2627. `------------------------------------------------------------------------*/
  2628. void
  2629. code_props_none_init (code_props *self)
  2630. {
  2631. *self = code_props_none;
  2632. }
  2633. code_props code_props_none = CODE_PROPS_NONE_INIT;
  2634. void
  2635. code_props_plain_init (code_props *self, char const *code,
  2636. location code_loc)
  2637. {
  2638. code_props_none_init (self);
  2639. self->kind = CODE_PROPS_PLAIN;
  2640. self->code = code;
  2641. self->location = code_loc;
  2642. }
  2643. void
  2644. code_props_symbol_action_init (code_props *self, char const *code,
  2645. location code_loc)
  2646. {
  2647. code_props_none_init (self);
  2648. self->kind = CODE_PROPS_SYMBOL_ACTION;
  2649. self->code = code;
  2650. self->location = code_loc;
  2651. }
  2652. void
  2653. code_props_rule_action_init (code_props *self, char const *code,
  2654. location code_loc, symbol_list *rule,
  2655. named_ref *name, uniqstr type,
  2656. bool is_predicate)
  2657. {
  2658. code_props_none_init (self);
  2659. self->kind = CODE_PROPS_RULE_ACTION;
  2660. self->code = code;
  2661. self->location = code_loc;
  2662. self->rule = rule;
  2663. self->named_ref = name;
  2664. self->type = type;
  2665. self->is_predicate = is_predicate;
  2666. }
  2667. void
  2668. code_props_translate_code (code_props *self)
  2669. {
  2670. switch (self->kind)
  2671. {
  2672. case CODE_PROPS_NONE:
  2673. break;
  2674. case CODE_PROPS_PLAIN:
  2675. self->code = translate_action (self, INITIAL);
  2676. break;
  2677. case CODE_PROPS_SYMBOL_ACTION:
  2678. self->code = translate_action (self, SC_SYMBOL_ACTION);
  2679. break;
  2680. case CODE_PROPS_RULE_ACTION:
  2681. self->code = translate_action (self, SC_RULE_ACTION);
  2682. break;
  2683. }
  2684. }
  2685. void
  2686. code_scanner_last_string_free (void)
  2687. {
  2688. STRING_FREE ();
  2689. }
  2690. void
  2691. code_scanner_free (void)
  2692. {
  2693. obstack_free (&obstack_for_string, 0);
  2694. variant_table_free ();
  2695. /* Reclaim Flex's buffers. */
  2696. yylex_destroy ();
  2697. }