Year 2 compilers coureswork

lex.yy.c 51KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073
  1. #line 3 "lex.yy.c"
  2. #define YY_INT_ALIGNED short int
  3. /* A lexical scanner generated by flex */
  4. #define FLEX_SCANNER
  5. #define YY_FLEX_MAJOR_VERSION 2
  6. #define YY_FLEX_MINOR_VERSION 5
  7. #define YY_FLEX_SUBMINOR_VERSION 35
  8. #if YY_FLEX_SUBMINOR_VERSION > 0
  9. #define FLEX_BETA
  10. #endif
  11. /* First, we deal with platform-specific or compiler-specific issues. */
  12. /* begin standard C headers. */
  13. #include <stdio.h>
  14. #include <string.h>
  15. #include <errno.h>
  16. #include <stdlib.h>
  17. /* end standard C headers. */
  18. /* flex integer type definitions */
  19. #ifndef FLEXINT_H
  20. #define FLEXINT_H
  21. /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
  22. #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  23. /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
  24. * if you want the limit (max/min) macros for int types.
  25. */
  26. #ifndef __STDC_LIMIT_MACROS
  27. #define __STDC_LIMIT_MACROS 1
  28. #endif
  29. #include <inttypes.h>
  30. typedef int8_t flex_int8_t;
  31. typedef uint8_t flex_uint8_t;
  32. typedef int16_t flex_int16_t;
  33. typedef uint16_t flex_uint16_t;
  34. typedef int32_t flex_int32_t;
  35. typedef uint32_t flex_uint32_t;
  36. typedef uint64_t flex_uint64_t;
  37. #else
  38. typedef signed char flex_int8_t;
  39. typedef short int flex_int16_t;
  40. typedef int flex_int32_t;
  41. typedef unsigned char flex_uint8_t;
  42. typedef unsigned short int flex_uint16_t;
  43. typedef unsigned int flex_uint32_t;
  44. #endif /* ! C99 */
  45. /* Limits of integral types. */
  46. #ifndef INT8_MIN
  47. #define INT8_MIN (-128)
  48. #endif
  49. #ifndef INT16_MIN
  50. #define INT16_MIN (-32767-1)
  51. #endif
  52. #ifndef INT32_MIN
  53. #define INT32_MIN (-2147483647-1)
  54. #endif
  55. #ifndef INT8_MAX
  56. #define INT8_MAX (127)
  57. #endif
  58. #ifndef INT16_MAX
  59. #define INT16_MAX (32767)
  60. #endif
  61. #ifndef INT32_MAX
  62. #define INT32_MAX (2147483647)
  63. #endif
  64. #ifndef UINT8_MAX
  65. #define UINT8_MAX (255U)
  66. #endif
  67. #ifndef UINT16_MAX
  68. #define UINT16_MAX (65535U)
  69. #endif
  70. #ifndef UINT32_MAX
  71. #define UINT32_MAX (4294967295U)
  72. #endif
  73. #endif /* ! FLEXINT_H */
  74. #ifdef __cplusplus
  75. /* The "const" storage-class-modifier is valid. */
  76. #define YY_USE_CONST
  77. #else /* ! __cplusplus */
  78. /* C99 requires __STDC__ to be defined as 1. */
  79. #if defined (__STDC__)
  80. #define YY_USE_CONST
  81. #endif /* defined (__STDC__) */
  82. #endif /* ! __cplusplus */
  83. #ifdef YY_USE_CONST
  84. #define yyconst const
  85. #else
  86. #define yyconst
  87. #endif
  88. /* Returned upon end-of-file. */
  89. #define YY_NULL 0
  90. /* Promotes a possibly negative, possibly signed char to an unsigned
  91. * integer for use as an array index. If the signed char is negative,
  92. * we want to instead treat it as an 8-bit unsigned char, hence the
  93. * double cast.
  94. */
  95. #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
  96. /* Enter a start condition. This macro really ought to take a parameter,
  97. * but we do it the disgusting crufty way forced on us by the ()-less
  98. * definition of BEGIN.
  99. */
  100. #define BEGIN (yy_start) = 1 + 2 *
  101. /* Translate the current start state into a value that can be later handed
  102. * to BEGIN to return to the state. The YYSTATE alias is for lex
  103. * compatibility.
  104. */
  105. #define YY_START (((yy_start) - 1) / 2)
  106. #define YYSTATE YY_START
  107. /* Action number for EOF rule of a given start state. */
  108. #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
  109. /* Special action meaning "start processing a new file". */
  110. #define YY_NEW_FILE yyrestart(yyin )
  111. #define YY_END_OF_BUFFER_CHAR 0
  112. /* Size of default input buffer. */
  113. #ifndef YY_BUF_SIZE
  114. #define YY_BUF_SIZE 16384
  115. #endif
  116. /* The state buf must be large enough to hold one state per character in the main buffer.
  117. */
  118. #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
  119. #ifndef YY_TYPEDEF_YY_BUFFER_STATE
  120. #define YY_TYPEDEF_YY_BUFFER_STATE
  121. typedef struct yy_buffer_state *YY_BUFFER_STATE;
  122. #endif
  123. #ifndef YY_TYPEDEF_YY_SIZE_T
  124. #define YY_TYPEDEF_YY_SIZE_T
  125. typedef size_t yy_size_t;
  126. #endif
  127. extern yy_size_t yyleng;
  128. extern FILE *yyin, *yyout;
  129. #define EOB_ACT_CONTINUE_SCAN 0
  130. #define EOB_ACT_END_OF_FILE 1
  131. #define EOB_ACT_LAST_MATCH 2
  132. #define YY_LESS_LINENO(n)
  133. /* Return all but the first "n" matched characters back to the input stream. */
  134. #define yyless(n) \
  135. do \
  136. { \
  137. /* Undo effects of setting up yytext. */ \
  138. int yyless_macro_arg = (n); \
  139. YY_LESS_LINENO(yyless_macro_arg);\
  140. *yy_cp = (yy_hold_char); \
  141. YY_RESTORE_YY_MORE_OFFSET \
  142. (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
  143. YY_DO_BEFORE_ACTION; /* set up yytext again */ \
  144. } \
  145. while ( 0 )
  146. #define unput(c) yyunput( c, (yytext_ptr) )
  147. #ifndef YY_STRUCT_YY_BUFFER_STATE
  148. #define YY_STRUCT_YY_BUFFER_STATE
  149. struct yy_buffer_state
  150. {
  151. FILE *yy_input_file;
  152. char *yy_ch_buf; /* input buffer */
  153. char *yy_buf_pos; /* current position in input buffer */
  154. /* Size of input buffer in bytes, not including room for EOB
  155. * characters.
  156. */
  157. yy_size_t yy_buf_size;
  158. /* Number of characters read into yy_ch_buf, not including EOB
  159. * characters.
  160. */
  161. yy_size_t yy_n_chars;
  162. /* Whether we "own" the buffer - i.e., we know we created it,
  163. * and can realloc() it to grow it, and should free() it to
  164. * delete it.
  165. */
  166. int yy_is_our_buffer;
  167. /* Whether this is an "interactive" input source; if so, and
  168. * if we're using stdio for input, then we want to use getc()
  169. * instead of fread(), to make sure we stop fetching input after
  170. * each newline.
  171. */
  172. int yy_is_interactive;
  173. /* Whether we're considered to be at the beginning of a line.
  174. * If so, '^' rules will be active on the next match, otherwise
  175. * not.
  176. */
  177. int yy_at_bol;
  178. int yy_bs_lineno; /**< The line count. */
  179. int yy_bs_column; /**< The column count. */
  180. /* Whether to try to fill the input buffer when we reach the
  181. * end of it.
  182. */
  183. int yy_fill_buffer;
  184. int yy_buffer_status;
  185. #define YY_BUFFER_NEW 0
  186. #define YY_BUFFER_NORMAL 1
  187. /* When an EOF's been seen but there's still some text to process
  188. * then we mark the buffer as YY_EOF_PENDING, to indicate that we
  189. * shouldn't try reading from the input source any more. We might
  190. * still have a bunch of tokens to match, though, because of
  191. * possible backing-up.
  192. *
  193. * When we actually see the EOF, we change the status to "new"
  194. * (via yyrestart()), so that the user can continue scanning by
  195. * just pointing yyin at a new input file.
  196. */
  197. #define YY_BUFFER_EOF_PENDING 2
  198. };
  199. #endif /* !YY_STRUCT_YY_BUFFER_STATE */
  200. /* Stack of input buffers. */
  201. static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
  202. static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
  203. static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
  204. /* We provide macros for accessing buffer states in case in the
  205. * future we want to put the buffer states in a more general
  206. * "scanner state".
  207. *
  208. * Returns the top of the stack, or NULL.
  209. */
  210. #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
  211. ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
  212. : NULL)
  213. /* Same as previous macro, but useful when we know that the buffer stack is not
  214. * NULL or when we need an lvalue. For internal use only.
  215. */
  216. #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
  217. /* yy_hold_char holds the character lost when yytext is formed. */
  218. static char yy_hold_char;
  219. static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */
  220. yy_size_t yyleng;
  221. /* Points to current character in buffer. */
  222. static char *yy_c_buf_p = (char *) 0;
  223. static int yy_init = 0; /* whether we need to initialize */
  224. static int yy_start = 0; /* start state number */
  225. /* Flag which is used to allow yywrap()'s to do buffer switches
  226. * instead of setting up a fresh yyin. A bit of a hack ...
  227. */
  228. static int yy_did_buffer_switch_on_eof;
  229. void yyrestart (FILE *input_file );
  230. void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer );
  231. YY_BUFFER_STATE yy_create_buffer (FILE *file,int size );
  232. void yy_delete_buffer (YY_BUFFER_STATE b );
  233. void yy_flush_buffer (YY_BUFFER_STATE b );
  234. void yypush_buffer_state (YY_BUFFER_STATE new_buffer );
  235. void yypop_buffer_state (void );
  236. static void yyensure_buffer_stack (void );
  237. static void yy_load_buffer_state (void );
  238. static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file );
  239. #define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER )
  240. YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size );
  241. YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str );
  242. YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len );
  243. void *yyalloc (yy_size_t );
  244. void *yyrealloc (void *,yy_size_t );
  245. void yyfree (void * );
  246. #define yy_new_buffer yy_create_buffer
  247. #define yy_set_interactive(is_interactive) \
  248. { \
  249. if ( ! YY_CURRENT_BUFFER ){ \
  250. yyensure_buffer_stack (); \
  251. YY_CURRENT_BUFFER_LVALUE = \
  252. yy_create_buffer(yyin,YY_BUF_SIZE ); \
  253. } \
  254. YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
  255. }
  256. #define yy_set_bol(at_bol) \
  257. { \
  258. if ( ! YY_CURRENT_BUFFER ){\
  259. yyensure_buffer_stack (); \
  260. YY_CURRENT_BUFFER_LVALUE = \
  261. yy_create_buffer(yyin,YY_BUF_SIZE ); \
  262. } \
  263. YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
  264. }
  265. #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
  266. /* Begin user sect3 */
  267. typedef unsigned char YY_CHAR;
  268. FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
  269. typedef int yy_state_type;
  270. extern int yylineno;
  271. int yylineno = 1;
  272. extern char *yytext;
  273. #define yytext_ptr yytext
  274. static yy_state_type yy_get_previous_state (void );
  275. static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
  276. static int yy_get_next_buffer (void );
  277. static void yy_fatal_error (yyconst char msg[] );
  278. /* Done after the current pattern has been matched and before the
  279. * corresponding action - sets up yytext.
  280. */
  281. #define YY_DO_BEFORE_ACTION \
  282. (yytext_ptr) = yy_bp; \
  283. yyleng = (yy_size_t) (yy_cp - yy_bp); \
  284. (yy_hold_char) = *yy_cp; \
  285. *yy_cp = '\0'; \
  286. (yy_c_buf_p) = yy_cp;
  287. #define YY_NUM_RULES 39
  288. #define YY_END_OF_BUFFER 40
  289. /* This struct is not used in this scanner,
  290. but its presence is necessary. */
  291. struct yy_trans_info
  292. {
  293. flex_int32_t yy_verify;
  294. flex_int32_t yy_nxt;
  295. };
  296. static yyconst flex_int16_t yy_accept[98] =
  297. { 0,
  298. 0, 0, 40, 38, 37, 37, 29, 38, 34, 38,
  299. 27, 28, 32, 31, 24, 30, 33, 14, 25, 21,
  300. 35, 26, 36, 13, 13, 13, 13, 13, 13, 13,
  301. 13, 13, 13, 13, 22, 23, 20, 0, 16, 0,
  302. 0, 0, 1, 14, 14, 17, 19, 18, 13, 0,
  303. 0, 13, 13, 13, 13, 13, 13, 7, 13, 13,
  304. 13, 13, 15, 13, 13, 13, 13, 13, 13, 8,
  305. 13, 13, 13, 2, 13, 13, 5, 13, 13, 13,
  306. 11, 13, 3, 13, 13, 13, 13, 12, 13, 6,
  307. 13, 10, 13, 13, 4, 9, 0
  308. } ;
  309. static yyconst flex_int32_t yy_ec[256] =
  310. { 0,
  311. 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
  312. 2, 2, 1, 1, 1, 1, 1, 1, 1, 1,
  313. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  314. 1, 2, 4, 5, 1, 1, 6, 1, 7, 8,
  315. 9, 10, 11, 12, 13, 1, 14, 15, 15, 15,
  316. 15, 15, 15, 15, 15, 15, 15, 16, 17, 18,
  317. 19, 20, 1, 1, 21, 21, 21, 21, 21, 21,
  318. 21, 21, 21, 21, 21, 22, 21, 21, 21, 21,
  319. 21, 21, 21, 21, 23, 21, 21, 21, 21, 21,
  320. 1, 24, 1, 1, 21, 1, 25, 26, 27, 28,
  321. 29, 30, 21, 31, 32, 21, 33, 34, 21, 35,
  322. 36, 21, 21, 37, 38, 39, 40, 41, 42, 43,
  323. 21, 21, 44, 1, 45, 1, 1, 1, 1, 1,
  324. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  325. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  326. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  327. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  328. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  329. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  330. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  331. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  332. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  333. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  334. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  335. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  336. 1, 1, 1, 1, 1
  337. } ;
  338. static yyconst flex_int32_t yy_meta[46] =
  339. { 0,
  340. 1, 1, 1, 1, 1, 1, 2, 1, 1, 1,
  341. 1, 1, 1, 1, 3, 1, 1, 1, 1, 1,
  342. 3, 3, 3, 1, 3, 3, 3, 3, 3, 3,
  343. 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
  344. 3, 3, 3, 1, 1
  345. } ;
  346. static yyconst flex_int16_t yy_base[101] =
  347. { 0,
  348. 0, 0, 130, 131, 131, 131, 110, 41, 131, 104,
  349. 131, 131, 131, 131, 131, 131, 117, 32, 131, 131,
  350. 107, 106, 105, 0, 43, 83, 85, 85, 15, 80,
  351. 21, 90, 82, 86, 131, 131, 131, 47, 131, 113,
  352. 46, 54, 131, 45, 40, 131, 131, 131, 0, 54,
  353. 91, 75, 84, 77, 73, 71, 74, 0, 69, 68,
  354. 74, 73, 131, 68, 78, 63, 72, 71, 72, 0,
  355. 58, 69, 62, 0, 62, 62, 0, 56, 53, 53,
  356. 0, 55, 0, 48, 47, 49, 42, 0, 36, 0,
  357. 39, 0, 44, 34, 0, 0, 131, 85, 88, 61
  358. } ;
  359. static yyconst flex_int16_t yy_def[101] =
  360. { 0,
  361. 97, 1, 97, 97, 97, 97, 97, 98, 97, 99,
  362. 97, 97, 97, 97, 97, 97, 97, 97, 97, 97,
  363. 97, 97, 97, 100, 100, 100, 100, 100, 100, 100,
  364. 100, 100, 100, 100, 97, 97, 97, 98, 97, 98,
  365. 99, 99, 97, 97, 97, 97, 97, 97, 100, 98,
  366. 99, 100, 100, 100, 100, 100, 100, 100, 100, 100,
  367. 100, 100, 97, 100, 100, 100, 100, 100, 100, 100,
  368. 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
  369. 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
  370. 100, 100, 100, 100, 100, 100, 0, 97, 97, 97
  371. } ;
  372. static yyconst flex_int16_t yy_nxt[177] =
  373. { 0,
  374. 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
  375. 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
  376. 24, 25, 24, 4, 26, 27, 28, 24, 29, 30,
  377. 24, 31, 24, 24, 24, 24, 32, 24, 24, 24,
  378. 33, 34, 24, 35, 36, 39, 44, 50, 55, 51,
  379. 58, 39, 63, 45, 45, 59, 97, 56, 39, 44,
  380. 41, 45, 45, 49, 40, 45, 45, 45, 96, 42,
  381. 40, 45, 95, 45, 94, 93, 92, 40, 45, 45,
  382. 91, 90, 89, 88, 45, 38, 38, 38, 41, 87,
  383. 41, 86, 85, 84, 83, 82, 81, 80, 79, 78,
  384. 77, 76, 75, 74, 73, 72, 71, 70, 69, 68,
  385. 67, 66, 65, 64, 42, 97, 62, 61, 60, 57,
  386. 54, 53, 52, 48, 47, 46, 43, 42, 37, 97,
  387. 3, 97, 97, 97, 97, 97, 97, 97, 97, 97,
  388. 97, 97, 97, 97, 97, 97, 97, 97, 97, 97,
  389. 97, 97, 97, 97, 97, 97, 97, 97, 97, 97,
  390. 97, 97, 97, 97, 97, 97, 97, 97, 97, 97,
  391. 97, 97, 97, 97, 97, 97
  392. } ;
  393. static yyconst flex_int16_t yy_chk[177] =
  394. { 0,
  395. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  396. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  397. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  398. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  399. 1, 1, 1, 1, 1, 8, 18, 25, 29, 25,
  400. 31, 38, 41, 18, 18, 31, 42, 29, 50, 44,
  401. 42, 45, 45, 100, 8, 18, 44, 44, 94, 41,
  402. 38, 18, 93, 45, 91, 89, 87, 50, 44, 45,
  403. 86, 85, 84, 82, 44, 98, 98, 98, 99, 80,
  404. 99, 79, 78, 76, 75, 73, 72, 71, 69, 68,
  405. 67, 66, 65, 64, 62, 61, 60, 59, 57, 56,
  406. 55, 54, 53, 52, 51, 40, 34, 33, 32, 30,
  407. 28, 27, 26, 23, 22, 21, 17, 10, 7, 3,
  408. 97, 97, 97, 97, 97, 97, 97, 97, 97, 97,
  409. 97, 97, 97, 97, 97, 97, 97, 97, 97, 97,
  410. 97, 97, 97, 97, 97, 97, 97, 97, 97, 97,
  411. 97, 97, 97, 97, 97, 97, 97, 97, 97, 97,
  412. 97, 97, 97, 97, 97, 97
  413. } ;
  414. static yy_state_type yy_last_accepting_state;
  415. static char *yy_last_accepting_cpos;
  416. extern int yy_flex_debug;
  417. int yy_flex_debug = 0;
  418. /* The intent behind this definition is that it'll catch
  419. * any uses of REJECT which flex missed.
  420. */
  421. #define REJECT reject_used_but_not_detected
  422. #define yymore() yymore_used_but_not_detected
  423. #define YY_MORE_ADJ 0
  424. #define YY_RESTORE_YY_MORE_OFFSET
  425. char *yytext;
  426. #line 1 "C.flex"
  427. #line 9 "C.flex"
  428. #pragma GCC diagnostic ignored "-Wall"
  429. #pragma GCC diagnostic ignored "-Wextra"
  430. #pragma GCC diagnostic ignored "-Wconversion"
  431. #pragma GCC diagnostic ignored "-Wpedantic"
  432. #pragma GCC diagnostic ignored "-Wint-to-pointer-cast"
  433. #include <stdio.h>
  434. #include "C.tab.h"
  435. #include <string.h>
  436. #include <stdlib.h>
  437. #include "token.h"
  438. TOKEN* make_string(char*);
  439. extern TOKEN* lookup_token(char*);
  440. TOKEN* make_int(char*);
  441. TOKEN* lasttok;
  442. void count(void);
  443. void comment(void);
  444. #line 538 "lex.yy.c"
  445. #define INITIAL 0
  446. #ifndef YY_NO_UNISTD_H
  447. /* Special case for "unistd.h", since it is non-ANSI. We include it way
  448. * down here because we want the user's section 1 to have been scanned first.
  449. * The user has a chance to override it with an option.
  450. */
  451. #include <unistd.h>
  452. #endif
  453. #ifndef YY_EXTRA_TYPE
  454. #define YY_EXTRA_TYPE void *
  455. #endif
  456. static int yy_init_globals (void );
  457. /* Accessor methods to globals.
  458. These are made visible to non-reentrant scanners for convenience. */
  459. int yylex_destroy (void );
  460. int yyget_debug (void );
  461. void yyset_debug (int debug_flag );
  462. YY_EXTRA_TYPE yyget_extra (void );
  463. void yyset_extra (YY_EXTRA_TYPE user_defined );
  464. FILE *yyget_in (void );
  465. void yyset_in (FILE * in_str );
  466. FILE *yyget_out (void );
  467. void yyset_out (FILE * out_str );
  468. yy_size_t yyget_leng (void );
  469. char *yyget_text (void );
  470. int yyget_lineno (void );
  471. void yyset_lineno (int line_number );
  472. /* Macros after this point can all be overridden by user definitions in
  473. * section 1.
  474. */
  475. #ifndef YY_SKIP_YYWRAP
  476. #ifdef __cplusplus
  477. extern "C" int yywrap (void );
  478. #else
  479. extern int yywrap (void );
  480. #endif
  481. #endif
  482. static void yyunput (int c,char *buf_ptr );
  483. #ifndef yytext_ptr
  484. static void yy_flex_strncpy (char *,yyconst char *,int );
  485. #endif
  486. #ifdef YY_NEED_STRLEN
  487. static int yy_flex_strlen (yyconst char * );
  488. #endif
  489. #ifndef YY_NO_INPUT
  490. #ifdef __cplusplus
  491. static int yyinput (void );
  492. #else
  493. static int input (void );
  494. #endif
  495. #endif
  496. /* Amount of stuff to slurp up with each read. */
  497. #ifndef YY_READ_BUF_SIZE
  498. #define YY_READ_BUF_SIZE 8192
  499. #endif
  500. /* Copy whatever the last rule matched to the standard output. */
  501. #ifndef ECHO
  502. /* This used to be an fputs(), but since the string might contain NUL's,
  503. * we now use fwrite().
  504. */
  505. #define ECHO fwrite( yytext, yyleng, 1, yyout )
  506. #endif
  507. /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
  508. * is returned in "result".
  509. */
  510. #ifndef YY_INPUT
  511. #define YY_INPUT(buf,result,max_size) \
  512. if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
  513. { \
  514. int c = '*'; \
  515. yy_size_t n; \
  516. for ( n = 0; n < max_size && \
  517. (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
  518. buf[n] = (char) c; \
  519. if ( c == '\n' ) \
  520. buf[n++] = (char) c; \
  521. if ( c == EOF && ferror( yyin ) ) \
  522. YY_FATAL_ERROR( "input in flex scanner failed" ); \
  523. result = n; \
  524. } \
  525. else \
  526. { \
  527. errno=0; \
  528. while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
  529. { \
  530. if( errno != EINTR) \
  531. { \
  532. YY_FATAL_ERROR( "input in flex scanner failed" ); \
  533. break; \
  534. } \
  535. errno=0; \
  536. clearerr(yyin); \
  537. } \
  538. }\
  539. \
  540. #endif
  541. /* No semi-colon after return; correct usage is to write "yyterminate();" -
  542. * we don't want an extra ';' after the "return" because that will cause
  543. * some compilers to complain about unreachable statements.
  544. */
  545. #ifndef yyterminate
  546. #define yyterminate() return YY_NULL
  547. #endif
  548. /* Number of entries by which start-condition stack grows. */
  549. #ifndef YY_START_STACK_INCR
  550. #define YY_START_STACK_INCR 25
  551. #endif
  552. /* Report a fatal error. */
  553. #ifndef YY_FATAL_ERROR
  554. #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
  555. #endif
  556. /* end tables serialization structures and prototypes */
  557. /* Default declaration of generated scanner - a define so the user can
  558. * easily add parameters.
  559. */
  560. #ifndef YY_DECL
  561. #define YY_DECL_IS_OURS 1
  562. extern int yylex (void);
  563. #define YY_DECL int yylex (void)
  564. #endif /* !YY_DECL */
  565. /* Code executed at the beginning of each rule, after yytext and yyleng
  566. * have been set up.
  567. */
  568. #ifndef YY_USER_ACTION
  569. #define YY_USER_ACTION
  570. #endif
  571. /* Code executed at the end of each rule. */
  572. #ifndef YY_BREAK
  573. #define YY_BREAK break;
  574. #endif
  575. #define YY_RULE_SETUP \
  576. YY_USER_ACTION
  577. /** The main scanner function which does all the work.
  578. */
  579. YY_DECL
  580. {
  581. register yy_state_type yy_current_state;
  582. register char *yy_cp, *yy_bp;
  583. register int yy_act;
  584. #line 28 "C.flex"
  585. #line 722 "lex.yy.c"
  586. if ( !(yy_init) )
  587. {
  588. (yy_init) = 1;
  589. #ifdef YY_USER_INIT
  590. YY_USER_INIT;
  591. #endif
  592. if ( ! (yy_start) )
  593. (yy_start) = 1; /* first start state */
  594. if ( ! yyin )
  595. yyin = stdin;
  596. if ( ! yyout )
  597. yyout = stdout;
  598. if ( ! YY_CURRENT_BUFFER ) {
  599. yyensure_buffer_stack ();
  600. YY_CURRENT_BUFFER_LVALUE =
  601. yy_create_buffer(yyin,YY_BUF_SIZE );
  602. }
  603. yy_load_buffer_state( );
  604. }
  605. while ( 1 ) /* loops until end-of-file is reached */
  606. {
  607. yy_cp = (yy_c_buf_p);
  608. /* Support of yytext. */
  609. *yy_cp = (yy_hold_char);
  610. /* yy_bp points to the position in yy_ch_buf of the start of
  611. * the current run.
  612. */
  613. yy_bp = yy_cp;
  614. yy_current_state = (yy_start);
  615. yy_match:
  616. do
  617. {
  618. register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
  619. if ( yy_accept[yy_current_state] )
  620. {
  621. (yy_last_accepting_state) = yy_current_state;
  622. (yy_last_accepting_cpos) = yy_cp;
  623. }
  624. while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  625. {
  626. yy_current_state = (int) yy_def[yy_current_state];
  627. if ( yy_current_state >= 98 )
  628. yy_c = yy_meta[(unsigned int) yy_c];
  629. }
  630. yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
  631. ++yy_cp;
  632. }
  633. while ( yy_base[yy_current_state] != 131 );
  634. yy_find_action:
  635. yy_act = yy_accept[yy_current_state];
  636. if ( yy_act == 0 )
  637. { /* have to back up */
  638. yy_cp = (yy_last_accepting_cpos);
  639. yy_current_state = (yy_last_accepting_state);
  640. yy_act = yy_accept[yy_current_state];
  641. }
  642. YY_DO_BEFORE_ACTION;
  643. do_action: /* This label is used only to access EOF actions. */
  644. switch ( yy_act )
  645. { /* beginning of action switch */
  646. case 0: /* must back up */
  647. /* undo the effects of YY_DO_BEFORE_ACTION */
  648. *yy_cp = (yy_hold_char);
  649. yy_cp = (yy_last_accepting_cpos);
  650. yy_current_state = (yy_last_accepting_state);
  651. goto yy_find_action;
  652. case 1:
  653. YY_RULE_SETUP
  654. #line 29 "C.flex"
  655. { comment(); }
  656. YY_BREAK
  657. case 2:
  658. YY_RULE_SETUP
  659. #line 31 "C.flex"
  660. { count(); return(AUTO); }
  661. YY_BREAK
  662. case 3:
  663. YY_RULE_SETUP
  664. #line 32 "C.flex"
  665. { count(); return(BREAK); }
  666. YY_BREAK
  667. case 4:
  668. YY_RULE_SETUP
  669. #line 33 "C.flex"
  670. { count(); return(CONTINUE); }
  671. YY_BREAK
  672. case 5:
  673. YY_RULE_SETUP
  674. #line 34 "C.flex"
  675. { count(); return(ELSE); }
  676. YY_BREAK
  677. case 6:
  678. YY_RULE_SETUP
  679. #line 35 "C.flex"
  680. { count(); return(EXTERN); }
  681. YY_BREAK
  682. case 7:
  683. YY_RULE_SETUP
  684. #line 36 "C.flex"
  685. { count(); return(IF); }
  686. YY_BREAK
  687. case 8:
  688. YY_RULE_SETUP
  689. #line 37 "C.flex"
  690. { count(); return(INT); }
  691. YY_BREAK
  692. case 9:
  693. YY_RULE_SETUP
  694. #line 38 "C.flex"
  695. { count(); return(FUNCTION); }
  696. YY_BREAK
  697. case 10:
  698. YY_RULE_SETUP
  699. #line 39 "C.flex"
  700. { count(); return(RETURN); }
  701. YY_BREAK
  702. case 11:
  703. YY_RULE_SETUP
  704. #line 40 "C.flex"
  705. { count(); return(VOID); }
  706. YY_BREAK
  707. case 12:
  708. YY_RULE_SETUP
  709. #line 41 "C.flex"
  710. { count(); return(WHILE); }
  711. YY_BREAK
  712. case 13:
  713. YY_RULE_SETUP
  714. #line 43 "C.flex"
  715. { count(); lasttok = lookup_token(yytext);
  716. return(IDENTIFIER); }
  717. YY_BREAK
  718. case 14:
  719. YY_RULE_SETUP
  720. #line 46 "C.flex"
  721. { count(); lasttok = make_int(yytext);return(CONSTANT); }
  722. YY_BREAK
  723. case 15:
  724. /* rule 15 can match eol */
  725. YY_RULE_SETUP
  726. #line 47 "C.flex"
  727. { count(); lasttok = make_int(yytext);return(CONSTANT); }
  728. YY_BREAK
  729. case 16:
  730. /* rule 16 can match eol */
  731. YY_RULE_SETUP
  732. #line 49 "C.flex"
  733. { count(); lasttok = make_string(yytext);
  734. return(STRING_LITERAL); }
  735. YY_BREAK
  736. case 17:
  737. YY_RULE_SETUP
  738. #line 52 "C.flex"
  739. { count(); return(LE_OP); }
  740. YY_BREAK
  741. case 18:
  742. YY_RULE_SETUP
  743. #line 53 "C.flex"
  744. { count(); return(GE_OP); }
  745. YY_BREAK
  746. case 19:
  747. YY_RULE_SETUP
  748. #line 54 "C.flex"
  749. { count(); return(EQ_OP); }
  750. YY_BREAK
  751. case 20:
  752. YY_RULE_SETUP
  753. #line 55 "C.flex"
  754. { count(); return(NE_OP); }
  755. YY_BREAK
  756. case 21:
  757. YY_RULE_SETUP
  758. #line 56 "C.flex"
  759. { count(); return(';'); }
  760. YY_BREAK
  761. case 22:
  762. YY_RULE_SETUP
  763. #line 57 "C.flex"
  764. { count(); return('{'); }
  765. YY_BREAK
  766. case 23:
  767. YY_RULE_SETUP
  768. #line 58 "C.flex"
  769. { count(); return('}'); }
  770. YY_BREAK
  771. case 24:
  772. YY_RULE_SETUP
  773. #line 59 "C.flex"
  774. { count(); return(','); }
  775. YY_BREAK
  776. case 25:
  777. YY_RULE_SETUP
  778. #line 60 "C.flex"
  779. { count(); return(':'); }
  780. YY_BREAK
  781. case 26:
  782. YY_RULE_SETUP
  783. #line 61 "C.flex"
  784. { count(); return('='); }
  785. YY_BREAK
  786. case 27:
  787. YY_RULE_SETUP
  788. #line 62 "C.flex"
  789. { count(); return('('); }
  790. YY_BREAK
  791. case 28:
  792. YY_RULE_SETUP
  793. #line 63 "C.flex"
  794. { count(); return(')'); }
  795. YY_BREAK
  796. case 29:
  797. YY_RULE_SETUP
  798. #line 64 "C.flex"
  799. { count(); return('!'); }
  800. YY_BREAK
  801. case 30:
  802. YY_RULE_SETUP
  803. #line 65 "C.flex"
  804. { count(); return('-'); }
  805. YY_BREAK
  806. case 31:
  807. YY_RULE_SETUP
  808. #line 66 "C.flex"
  809. { count(); return('+'); }
  810. YY_BREAK
  811. case 32:
  812. YY_RULE_SETUP
  813. #line 67 "C.flex"
  814. { count(); return('*'); }
  815. YY_BREAK
  816. case 33:
  817. YY_RULE_SETUP
  818. #line 68 "C.flex"
  819. { count(); return('/'); }
  820. YY_BREAK
  821. case 34:
  822. YY_RULE_SETUP
  823. #line 69 "C.flex"
  824. { count(); return('%'); }
  825. YY_BREAK
  826. case 35:
  827. YY_RULE_SETUP
  828. #line 70 "C.flex"
  829. { count(); return('<'); }
  830. YY_BREAK
  831. case 36:
  832. YY_RULE_SETUP
  833. #line 71 "C.flex"
  834. { count(); return('>'); }
  835. YY_BREAK
  836. case 37:
  837. /* rule 37 can match eol */
  838. YY_RULE_SETUP
  839. #line 73 "C.flex"
  840. { count(); }
  841. YY_BREAK
  842. case 38:
  843. YY_RULE_SETUP
  844. #line 74 "C.flex"
  845. { /* ignore bad characters */ }
  846. YY_BREAK
  847. case 39:
  848. YY_RULE_SETUP
  849. #line 76 "C.flex"
  850. ECHO;
  851. YY_BREAK
  852. #line 1005 "lex.yy.c"
  853. case YY_STATE_EOF(INITIAL):
  854. yyterminate();
  855. case YY_END_OF_BUFFER:
  856. {
  857. /* Amount of text matched not including the EOB char. */
  858. int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
  859. /* Undo the effects of YY_DO_BEFORE_ACTION. */
  860. *yy_cp = (yy_hold_char);
  861. YY_RESTORE_YY_MORE_OFFSET
  862. if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
  863. {
  864. /* We're scanning a new file or input source. It's
  865. * possible that this happened because the user
  866. * just pointed yyin at a new source and called
  867. * yylex(). If so, then we have to assure
  868. * consistency between YY_CURRENT_BUFFER and our
  869. * globals. Here is the right place to do so, because
  870. * this is the first action (other than possibly a
  871. * back-up) that will match for the new input source.
  872. */
  873. (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
  874. YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
  875. YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
  876. }
  877. /* Note that here we test for yy_c_buf_p "<=" to the position
  878. * of the first EOB in the buffer, since yy_c_buf_p will
  879. * already have been incremented past the NUL character
  880. * (since all states make transitions on EOB to the
  881. * end-of-buffer state). Contrast this with the test
  882. * in input().
  883. */
  884. if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
  885. { /* This was really a NUL. */
  886. yy_state_type yy_next_state;
  887. (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
  888. yy_current_state = yy_get_previous_state( );
  889. /* Okay, we're now positioned to make the NUL
  890. * transition. We couldn't have
  891. * yy_get_previous_state() go ahead and do it
  892. * for us because it doesn't know how to deal
  893. * with the possibility of jamming (and we don't
  894. * want to build jamming into it because then it
  895. * will run more slowly).
  896. */
  897. yy_next_state = yy_try_NUL_trans( yy_current_state );
  898. yy_bp = (yytext_ptr) + YY_MORE_ADJ;
  899. if ( yy_next_state )
  900. {
  901. /* Consume the NUL. */
  902. yy_cp = ++(yy_c_buf_p);
  903. yy_current_state = yy_next_state;
  904. goto yy_match;
  905. }
  906. else
  907. {
  908. yy_cp = (yy_c_buf_p);
  909. goto yy_find_action;
  910. }
  911. }
  912. else switch ( yy_get_next_buffer( ) )
  913. {
  914. case EOB_ACT_END_OF_FILE:
  915. {
  916. (yy_did_buffer_switch_on_eof) = 0;
  917. if ( yywrap( ) )
  918. {
  919. /* Note: because we've taken care in
  920. * yy_get_next_buffer() to have set up
  921. * yytext, we can now set up
  922. * yy_c_buf_p so that if some total
  923. * hoser (like flex itself) wants to
  924. * call the scanner after we return the
  925. * YY_NULL, it'll still work - another
  926. * YY_NULL will get returned.
  927. */
  928. (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
  929. yy_act = YY_STATE_EOF(YY_START);
  930. goto do_action;
  931. }
  932. else
  933. {
  934. if ( ! (yy_did_buffer_switch_on_eof) )
  935. YY_NEW_FILE;
  936. }
  937. break;
  938. }
  939. case EOB_ACT_CONTINUE_SCAN:
  940. (yy_c_buf_p) =
  941. (yytext_ptr) + yy_amount_of_matched_text;
  942. yy_current_state = yy_get_previous_state( );
  943. yy_cp = (yy_c_buf_p);
  944. yy_bp = (yytext_ptr) + YY_MORE_ADJ;
  945. goto yy_match;
  946. case EOB_ACT_LAST_MATCH:
  947. (yy_c_buf_p) =
  948. &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
  949. yy_current_state = yy_get_previous_state( );
  950. yy_cp = (yy_c_buf_p);
  951. yy_bp = (yytext_ptr) + YY_MORE_ADJ;
  952. goto yy_find_action;
  953. }
  954. break;
  955. }
  956. default:
  957. YY_FATAL_ERROR(
  958. "fatal flex scanner internal error--no action found" );
  959. } /* end of action switch */
  960. } /* end of scanning one token */
  961. } /* end of yylex */
  962. /* yy_get_next_buffer - try to read in a new buffer
  963. *
  964. * Returns a code representing an action:
  965. * EOB_ACT_LAST_MATCH -
  966. * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
  967. * EOB_ACT_END_OF_FILE - end of file
  968. */
  969. static int yy_get_next_buffer (void)
  970. {
  971. register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
  972. register char *source = (yytext_ptr);
  973. register int number_to_move, i;
  974. int ret_val;
  975. if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
  976. YY_FATAL_ERROR(
  977. "fatal flex scanner internal error--end of buffer missed" );
  978. if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
  979. { /* Don't try to fill the buffer, so this is an EOF. */
  980. if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
  981. {
  982. /* We matched a single character, the EOB, so
  983. * treat this as a final EOF.
  984. */
  985. return EOB_ACT_END_OF_FILE;
  986. }
  987. else
  988. {
  989. /* We matched some text prior to the EOB, first
  990. * process it.
  991. */
  992. return EOB_ACT_LAST_MATCH;
  993. }
  994. }
  995. /* Try to read more data. */
  996. /* First move last chars to start of buffer. */
  997. number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
  998. for ( i = 0; i < number_to_move; ++i )
  999. *(dest++) = *(source++);
  1000. if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
  1001. /* don't do the read, it's not guaranteed to return an EOF,
  1002. * just force an EOF
  1003. */
  1004. YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
  1005. else
  1006. {
  1007. yy_size_t num_to_read =
  1008. YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
  1009. while ( num_to_read <= 0 )
  1010. { /* Not enough room in the buffer - grow it. */
  1011. /* just a shorter name for the current buffer */
  1012. YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
  1013. int yy_c_buf_p_offset =
  1014. (int) ((yy_c_buf_p) - b->yy_ch_buf);
  1015. if ( b->yy_is_our_buffer )
  1016. {
  1017. yy_size_t new_size = b->yy_buf_size * 2;
  1018. if ( new_size <= 0 )
  1019. b->yy_buf_size += b->yy_buf_size / 8;
  1020. else
  1021. b->yy_buf_size *= 2;
  1022. b->yy_ch_buf = (char *)
  1023. /* Include room in for 2 EOB chars. */
  1024. yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
  1025. }
  1026. else
  1027. /* Can't grow it, we don't own it. */
  1028. b->yy_ch_buf = 0;
  1029. if ( ! b->yy_ch_buf )
  1030. YY_FATAL_ERROR(
  1031. "fatal error - scanner input buffer overflow" );
  1032. (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
  1033. num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
  1034. number_to_move - 1;
  1035. }
  1036. if ( num_to_read > YY_READ_BUF_SIZE )
  1037. num_to_read = YY_READ_BUF_SIZE;
  1038. /* Read in more data. */
  1039. YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
  1040. (yy_n_chars), num_to_read );
  1041. YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
  1042. }
  1043. if ( (yy_n_chars) == 0 )
  1044. {
  1045. if ( number_to_move == YY_MORE_ADJ )
  1046. {
  1047. ret_val = EOB_ACT_END_OF_FILE;
  1048. yyrestart(yyin );
  1049. }
  1050. else
  1051. {
  1052. ret_val = EOB_ACT_LAST_MATCH;
  1053. YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
  1054. YY_BUFFER_EOF_PENDING;
  1055. }
  1056. }
  1057. else
  1058. ret_val = EOB_ACT_CONTINUE_SCAN;
  1059. if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
  1060. /* Extend the array by 50%, plus the number we really need. */
  1061. yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
  1062. YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
  1063. if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
  1064. YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
  1065. }
  1066. (yy_n_chars) += number_to_move;
  1067. YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
  1068. YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
  1069. (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
  1070. return ret_val;
  1071. }
  1072. /* yy_get_previous_state - get the state just before the EOB char was reached */
  1073. static yy_state_type yy_get_previous_state (void)
  1074. {
  1075. register yy_state_type yy_current_state;
  1076. register char *yy_cp;
  1077. yy_current_state = (yy_start);
  1078. for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
  1079. {
  1080. register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
  1081. if ( yy_accept[yy_current_state] )
  1082. {
  1083. (yy_last_accepting_state) = yy_current_state;
  1084. (yy_last_accepting_cpos) = yy_cp;
  1085. }
  1086. while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  1087. {
  1088. yy_current_state = (int) yy_def[yy_current_state];
  1089. if ( yy_current_state >= 98 )
  1090. yy_c = yy_meta[(unsigned int) yy_c];
  1091. }
  1092. yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
  1093. }
  1094. return yy_current_state;
  1095. }
  1096. /* yy_try_NUL_trans - try to make a transition on the NUL character
  1097. *
  1098. * synopsis
  1099. * next_state = yy_try_NUL_trans( current_state );
  1100. */
  1101. static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
  1102. {
  1103. register int yy_is_jam;
  1104. register char *yy_cp = (yy_c_buf_p);
  1105. register YY_CHAR yy_c = 1;
  1106. if ( yy_accept[yy_current_state] )
  1107. {
  1108. (yy_last_accepting_state) = yy_current_state;
  1109. (yy_last_accepting_cpos) = yy_cp;
  1110. }
  1111. while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  1112. {
  1113. yy_current_state = (int) yy_def[yy_current_state];
  1114. if ( yy_current_state >= 98 )
  1115. yy_c = yy_meta[(unsigned int) yy_c];
  1116. }
  1117. yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
  1118. yy_is_jam = (yy_current_state == 97);
  1119. return yy_is_jam ? 0 : yy_current_state;
  1120. }
  1121. static void yyunput (int c, register char * yy_bp )
  1122. {
  1123. register char *yy_cp;
  1124. yy_cp = (yy_c_buf_p);
  1125. /* undo effects of setting up yytext */
  1126. *yy_cp = (yy_hold_char);
  1127. if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
  1128. { /* need to shift things up to make room */
  1129. /* +2 for EOB chars. */
  1130. register yy_size_t number_to_move = (yy_n_chars) + 2;
  1131. register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
  1132. YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
  1133. register char *source =
  1134. &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
  1135. while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
  1136. *--dest = *--source;
  1137. yy_cp += (int) (dest - source);
  1138. yy_bp += (int) (dest - source);
  1139. YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
  1140. (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
  1141. if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
  1142. YY_FATAL_ERROR( "flex scanner push-back overflow" );
  1143. }
  1144. *--yy_cp = (char) c;
  1145. (yytext_ptr) = yy_bp;
  1146. (yy_hold_char) = *yy_cp;
  1147. (yy_c_buf_p) = yy_cp;
  1148. }
  1149. #ifndef YY_NO_INPUT
  1150. #ifdef __cplusplus
  1151. static int yyinput (void)
  1152. #else
  1153. static int input (void)
  1154. #endif
  1155. {
  1156. int c;
  1157. *(yy_c_buf_p) = (yy_hold_char);
  1158. if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
  1159. {
  1160. /* yy_c_buf_p now points to the character we want to return.
  1161. * If this occurs *before* the EOB characters, then it's a
  1162. * valid NUL; if not, then we've hit the end of the buffer.
  1163. */
  1164. if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
  1165. /* This was really a NUL. */
  1166. *(yy_c_buf_p) = '\0';
  1167. else
  1168. { /* need more input */
  1169. yy_size_t offset = (yy_c_buf_p) - (yytext_ptr);
  1170. ++(yy_c_buf_p);
  1171. switch ( yy_get_next_buffer( ) )
  1172. {
  1173. case EOB_ACT_LAST_MATCH:
  1174. /* This happens because yy_g_n_b()
  1175. * sees that we've accumulated a
  1176. * token and flags that we need to
  1177. * try matching the token before
  1178. * proceeding. But for input(),
  1179. * there's no matching to consider.
  1180. * So convert the EOB_ACT_LAST_MATCH
  1181. * to EOB_ACT_END_OF_FILE.
  1182. */
  1183. /* Reset buffer status. */
  1184. yyrestart(yyin );
  1185. /*FALLTHROUGH*/
  1186. case EOB_ACT_END_OF_FILE:
  1187. {
  1188. if ( yywrap( ) )
  1189. return 0;
  1190. if ( ! (yy_did_buffer_switch_on_eof) )
  1191. YY_NEW_FILE;
  1192. #ifdef __cplusplus
  1193. return yyinput();
  1194. #else
  1195. return input();
  1196. #endif
  1197. }
  1198. case EOB_ACT_CONTINUE_SCAN:
  1199. (yy_c_buf_p) = (yytext_ptr) + offset;
  1200. break;
  1201. }
  1202. }
  1203. }
  1204. c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
  1205. *(yy_c_buf_p) = '\0'; /* preserve yytext */
  1206. (yy_hold_char) = *++(yy_c_buf_p);
  1207. return c;
  1208. }
  1209. #endif /* ifndef YY_NO_INPUT */
  1210. /** Immediately switch to a different input stream.
  1211. * @param input_file A readable stream.
  1212. *
  1213. * @note This function does not reset the start condition to @c INITIAL .
  1214. */
  1215. void yyrestart (FILE * input_file )
  1216. {
  1217. if ( ! YY_CURRENT_BUFFER ){
  1218. yyensure_buffer_stack ();
  1219. YY_CURRENT_BUFFER_LVALUE =
  1220. yy_create_buffer(yyin,YY_BUF_SIZE );
  1221. }
  1222. yy_init_buffer(YY_CURRENT_BUFFER,input_file );
  1223. yy_load_buffer_state( );
  1224. }
  1225. /** Switch to a different input buffer.
  1226. * @param new_buffer The new input buffer.
  1227. *
  1228. */
  1229. void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer )
  1230. {
  1231. /* TODO. We should be able to replace this entire function body
  1232. * with
  1233. * yypop_buffer_state();
  1234. * yypush_buffer_state(new_buffer);
  1235. */
  1236. yyensure_buffer_stack ();
  1237. if ( YY_CURRENT_BUFFER == new_buffer )
  1238. return;
  1239. if ( YY_CURRENT_BUFFER )
  1240. {
  1241. /* Flush out information for old buffer. */
  1242. *(yy_c_buf_p) = (yy_hold_char);
  1243. YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
  1244. YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
  1245. }
  1246. YY_CURRENT_BUFFER_LVALUE = new_buffer;
  1247. yy_load_buffer_state( );
  1248. /* We don't actually know whether we did this switch during
  1249. * EOF (yywrap()) processing, but the only time this flag
  1250. * is looked at is after yywrap() is called, so it's safe
  1251. * to go ahead and always set it.
  1252. */
  1253. (yy_did_buffer_switch_on_eof) = 1;
  1254. }
  1255. static void yy_load_buffer_state (void)
  1256. {
  1257. (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
  1258. (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
  1259. yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
  1260. (yy_hold_char) = *(yy_c_buf_p);
  1261. }
  1262. /** Allocate and initialize an input buffer state.
  1263. * @param file A readable stream.
  1264. * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
  1265. *
  1266. * @return the allocated buffer state.
  1267. */
  1268. YY_BUFFER_STATE yy_create_buffer (FILE * file, int size )
  1269. {
  1270. YY_BUFFER_STATE b;
  1271. b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
  1272. if ( ! b )
  1273. YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
  1274. b->yy_buf_size = size;
  1275. /* yy_ch_buf has to be 2 characters longer than the size given because
  1276. * we need to put in 2 end-of-buffer characters.
  1277. */
  1278. b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 );
  1279. if ( ! b->yy_ch_buf )
  1280. YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
  1281. b->yy_is_our_buffer = 1;
  1282. yy_init_buffer(b,file );
  1283. return b;
  1284. }
  1285. /** Destroy the buffer.
  1286. * @param b a buffer created with yy_create_buffer()
  1287. *
  1288. */
  1289. void yy_delete_buffer (YY_BUFFER_STATE b )
  1290. {
  1291. if ( ! b )
  1292. return;
  1293. if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
  1294. YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
  1295. if ( b->yy_is_our_buffer )
  1296. yyfree((void *) b->yy_ch_buf );
  1297. yyfree((void *) b );
  1298. }
  1299. #ifndef __cplusplus
  1300. extern int isatty (int );
  1301. #endif /* __cplusplus */
  1302. /* Initializes or reinitializes a buffer.
  1303. * This function is sometimes called more than once on the same buffer,
  1304. * such as during a yyrestart() or at EOF.
  1305. */
  1306. static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file )
  1307. {
  1308. int oerrno = errno;
  1309. yy_flush_buffer(b );
  1310. b->yy_input_file = file;
  1311. b->yy_fill_buffer = 1;
  1312. /* If b is the current buffer, then yy_init_buffer was _probably_
  1313. * called from yyrestart() or through yy_get_next_buffer.
  1314. * In that case, we don't want to reset the lineno or column.
  1315. */
  1316. if (b != YY_CURRENT_BUFFER){
  1317. b->yy_bs_lineno = 1;
  1318. b->yy_bs_column = 0;
  1319. }
  1320. b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
  1321. errno = oerrno;
  1322. }
  1323. /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
  1324. * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
  1325. *
  1326. */
  1327. void yy_flush_buffer (YY_BUFFER_STATE b )
  1328. {
  1329. if ( ! b )
  1330. return;
  1331. b->yy_n_chars = 0;
  1332. /* We always need two end-of-buffer characters. The first causes
  1333. * a transition to the end-of-buffer state. The second causes
  1334. * a jam in that state.
  1335. */
  1336. b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
  1337. b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
  1338. b->yy_buf_pos = &b->yy_ch_buf[0];
  1339. b->yy_at_bol = 1;
  1340. b->yy_buffer_status = YY_BUFFER_NEW;
  1341. if ( b == YY_CURRENT_BUFFER )
  1342. yy_load_buffer_state( );
  1343. }
  1344. /** Pushes the new state onto the stack. The new state becomes
  1345. * the current state. This function will allocate the stack
  1346. * if necessary.
  1347. * @param new_buffer The new state.
  1348. *
  1349. */
  1350. void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
  1351. {
  1352. if (new_buffer == NULL)
  1353. return;
  1354. yyensure_buffer_stack();
  1355. /* This block is copied from yy_switch_to_buffer. */
  1356. if ( YY_CURRENT_BUFFER )
  1357. {
  1358. /* Flush out information for old buffer. */
  1359. *(yy_c_buf_p) = (yy_hold_char);
  1360. YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
  1361. YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
  1362. }
  1363. /* Only push if top exists. Otherwise, replace top. */
  1364. if (YY_CURRENT_BUFFER)
  1365. (yy_buffer_stack_top)++;
  1366. YY_CURRENT_BUFFER_LVALUE = new_buffer;
  1367. /* copied from yy_switch_to_buffer. */
  1368. yy_load_buffer_state( );
  1369. (yy_did_buffer_switch_on_eof) = 1;
  1370. }
  1371. /** Removes and deletes the top of the stack, if present.
  1372. * The next element becomes the new top.
  1373. *
  1374. */
  1375. void yypop_buffer_state (void)
  1376. {
  1377. if (!YY_CURRENT_BUFFER)
  1378. return;
  1379. yy_delete_buffer(YY_CURRENT_BUFFER );
  1380. YY_CURRENT_BUFFER_LVALUE = NULL;
  1381. if ((yy_buffer_stack_top) > 0)
  1382. --(yy_buffer_stack_top);
  1383. if (YY_CURRENT_BUFFER) {
  1384. yy_load_buffer_state( );
  1385. (yy_did_buffer_switch_on_eof) = 1;
  1386. }
  1387. }
  1388. /* Allocates the stack if it does not exist.
  1389. * Guarantees space for at least one push.
  1390. */
  1391. static void yyensure_buffer_stack (void)
  1392. {
  1393. yy_size_t num_to_alloc;
  1394. if (!(yy_buffer_stack)) {
  1395. /* First allocation is just for 2 elements, since we don't know if this
  1396. * scanner will even need a stack. We use 2 instead of 1 to avoid an
  1397. * immediate realloc on the next call.
  1398. */
  1399. num_to_alloc = 1;
  1400. (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
  1401. (num_to_alloc * sizeof(struct yy_buffer_state*)
  1402. );
  1403. if ( ! (yy_buffer_stack) )
  1404. YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
  1405. memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
  1406. (yy_buffer_stack_max) = num_to_alloc;
  1407. (yy_buffer_stack_top) = 0;
  1408. return;
  1409. }
  1410. if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
  1411. /* Increase the buffer to prepare for a possible push. */
  1412. int grow_size = 8 /* arbitrary grow size */;
  1413. num_to_alloc = (yy_buffer_stack_max) + grow_size;
  1414. (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
  1415. ((yy_buffer_stack),
  1416. num_to_alloc * sizeof(struct yy_buffer_state*)
  1417. );
  1418. if ( ! (yy_buffer_stack) )
  1419. YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
  1420. /* zero only the new slots.*/
  1421. memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
  1422. (yy_buffer_stack_max) = num_to_alloc;
  1423. }
  1424. }
  1425. /** Setup the input buffer state to scan directly from a user-specified character buffer.
  1426. * @param base the character buffer
  1427. * @param size the size in bytes of the character buffer
  1428. *
  1429. * @return the newly allocated buffer state object.
  1430. */
  1431. YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
  1432. {
  1433. YY_BUFFER_STATE b;
  1434. if ( size < 2 ||
  1435. base[size-2] != YY_END_OF_BUFFER_CHAR ||
  1436. base[size-1] != YY_END_OF_BUFFER_CHAR )
  1437. /* They forgot to leave room for the EOB's. */
  1438. return 0;
  1439. b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
  1440. if ( ! b )
  1441. YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
  1442. b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
  1443. b->yy_buf_pos = b->yy_ch_buf = base;
  1444. b->yy_is_our_buffer = 0;
  1445. b->yy_input_file = 0;
  1446. b->yy_n_chars = b->yy_buf_size;
  1447. b->yy_is_interactive = 0;
  1448. b->yy_at_bol = 1;
  1449. b->yy_fill_buffer = 0;
  1450. b->yy_buffer_status = YY_BUFFER_NEW;
  1451. yy_switch_to_buffer(b );
  1452. return b;
  1453. }
  1454. /** Setup the input buffer state to scan a string. The next call to yylex() will
  1455. * scan from a @e copy of @a str.
  1456. * @param yystr a NUL-terminated string to scan
  1457. *
  1458. * @return the newly allocated buffer state object.
  1459. * @note If you want to scan bytes that may contain NUL values, then use
  1460. * yy_scan_bytes() instead.
  1461. */
  1462. YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
  1463. {
  1464. return yy_scan_bytes(yystr,strlen(yystr) );
  1465. }
  1466. /** Setup the input buffer state to scan the given bytes. The next call to yylex() will
  1467. * scan from a @e copy of @a bytes.
  1468. * @param bytes the byte buffer to scan
  1469. * @param len the number of bytes in the buffer pointed to by @a bytes.
  1470. *
  1471. * @return the newly allocated buffer state object.
  1472. */
  1473. YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len )
  1474. {
  1475. YY_BUFFER_STATE b;
  1476. char *buf;
  1477. yy_size_t n, i;
  1478. /* Get memory for full buffer, including space for trailing EOB's. */
  1479. n = _yybytes_len + 2;
  1480. buf = (char *) yyalloc(n );
  1481. if ( ! buf )
  1482. YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
  1483. for ( i = 0; i < _yybytes_len; ++i )
  1484. buf[i] = yybytes[i];
  1485. buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
  1486. b = yy_scan_buffer(buf,n );
  1487. if ( ! b )
  1488. YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
  1489. /* It's okay to grow etc. this buffer, and we should throw it
  1490. * away when we're done.
  1491. */
  1492. b->yy_is_our_buffer = 1;
  1493. return b;
  1494. }
  1495. #ifndef YY_EXIT_FAILURE
  1496. #define YY_EXIT_FAILURE 2
  1497. #endif
  1498. static void yy_fatal_error (yyconst char* msg )
  1499. {
  1500. (void) fprintf( stderr, "%s\n", msg );
  1501. exit( YY_EXIT_FAILURE );
  1502. }
  1503. /* Redefine yyless() so it works in section 3 code. */
  1504. #undef yyless
  1505. #define yyless(n) \
  1506. do \
  1507. { \
  1508. /* Undo effects of setting up yytext. */ \
  1509. int yyless_macro_arg = (n); \
  1510. YY_LESS_LINENO(yyless_macro_arg);\
  1511. yytext[yyleng] = (yy_hold_char); \
  1512. (yy_c_buf_p) = yytext + yyless_macro_arg; \
  1513. (yy_hold_char) = *(yy_c_buf_p); \
  1514. *(yy_c_buf_p) = '\0'; \
  1515. yyleng = yyless_macro_arg; \
  1516. } \
  1517. while ( 0 )
  1518. /* Accessor methods (get/set functions) to struct members. */
  1519. /** Get the current line number.
  1520. *
  1521. */
  1522. int yyget_lineno (void)
  1523. {
  1524. return yylineno;
  1525. }
  1526. /** Get the input stream.
  1527. *
  1528. */
  1529. FILE *yyget_in (void)
  1530. {
  1531. return yyin;
  1532. }
  1533. /** Get the output stream.
  1534. *
  1535. */
  1536. FILE *yyget_out (void)
  1537. {
  1538. return yyout;
  1539. }
  1540. /** Get the length of the current token.
  1541. *
  1542. */
  1543. yy_size_t yyget_leng (void)
  1544. {
  1545. return yyleng;
  1546. }
  1547. /** Get the current token.
  1548. *
  1549. */
  1550. char *yyget_text (void)
  1551. {
  1552. return yytext;
  1553. }
  1554. /** Set the current line number.
  1555. * @param line_number
  1556. *
  1557. */
  1558. void yyset_lineno (int line_number )
  1559. {
  1560. yylineno = line_number;
  1561. }
  1562. /** Set the input stream. This does not discard the current
  1563. * input buffer.
  1564. * @param in_str A readable stream.
  1565. *
  1566. * @see yy_switch_to_buffer
  1567. */
  1568. void yyset_in (FILE * in_str )
  1569. {
  1570. yyin = in_str ;
  1571. }
  1572. void yyset_out (FILE * out_str )
  1573. {
  1574. yyout = out_str ;
  1575. }
  1576. int yyget_debug (void)
  1577. {
  1578. return yy_flex_debug;
  1579. }
  1580. void yyset_debug (int bdebug )
  1581. {
  1582. yy_flex_debug = bdebug ;
  1583. }
  1584. static int yy_init_globals (void)
  1585. {
  1586. /* Initialization is the same as for the non-reentrant scanner.
  1587. * This function is called from yylex_destroy(), so don't allocate here.
  1588. */
  1589. (yy_buffer_stack) = 0;
  1590. (yy_buffer_stack_top) = 0;
  1591. (yy_buffer_stack_max) = 0;
  1592. (yy_c_buf_p) = (char *) 0;
  1593. (yy_init) = 0;
  1594. (yy_start) = 0;
  1595. /* Defined in main.c */
  1596. #ifdef YY_STDINIT
  1597. yyin = stdin;
  1598. yyout = stdout;
  1599. #else
  1600. yyin = (FILE *) 0;
  1601. yyout = (FILE *) 0;
  1602. #endif
  1603. /* For future reference: Set errno on error, since we are called by
  1604. * yylex_init()
  1605. */
  1606. return 0;
  1607. }
  1608. /* yylex_destroy is for both reentrant and non-reentrant scanners. */
  1609. int yylex_destroy (void)
  1610. {
  1611. /* Pop the buffer stack, destroying each element. */
  1612. while(YY_CURRENT_BUFFER){
  1613. yy_delete_buffer(YY_CURRENT_BUFFER );
  1614. YY_CURRENT_BUFFER_LVALUE = NULL;
  1615. yypop_buffer_state();
  1616. }
  1617. /* Destroy the stack itself. */
  1618. yyfree((yy_buffer_stack) );
  1619. (yy_buffer_stack) = NULL;
  1620. /* Reset the globals. This is important in a non-reentrant scanner so the next time
  1621. * yylex() is called, initialization will occur. */
  1622. yy_init_globals( );
  1623. return 0;
  1624. }
  1625. /*
  1626. * Internal utility routines.
  1627. */
  1628. #ifndef yytext_ptr
  1629. static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
  1630. {
  1631. register int i;
  1632. for ( i = 0; i < n; ++i )
  1633. s1[i] = s2[i];
  1634. }
  1635. #endif
  1636. #ifdef YY_NEED_STRLEN
  1637. static int yy_flex_strlen (yyconst char * s )
  1638. {
  1639. register int n;
  1640. for ( n = 0; s[n]; ++n )
  1641. ;
  1642. return n;
  1643. }
  1644. #endif
  1645. void *yyalloc (yy_size_t size )
  1646. {
  1647. return (void *) malloc( size );
  1648. }
  1649. void *yyrealloc (void * ptr, yy_size_t size )
  1650. {
  1651. /* The cast to (char *) in the following accommodates both
  1652. * implementations that use char* generic pointers, and those
  1653. * that use void* generic pointers. It works with the latter
  1654. * because both ANSI C and C++ allow castless assignment from
  1655. * any pointer type to void*, and deal with argument conversions
  1656. * as though doing an assignment.
  1657. */
  1658. return (void *) realloc( (char *) ptr, size );
  1659. }
  1660. void yyfree (void * ptr )
  1661. {
  1662. free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
  1663. }
  1664. #define YYTABLES_NAME "yytables"
  1665. #line 76 "C.flex"
  1666. int yywrap(void)
  1667. {
  1668. return(1);
  1669. }
  1670. void comment(void)
  1671. {
  1672. char c, c1;
  1673. loop:
  1674. while ((c = input()) != '*' && c != 0)
  1675. putchar(c);
  1676. if ((c1 = input()) != '/' && c != 0)
  1677. {
  1678. unput(c1);
  1679. goto loop;
  1680. }
  1681. if (c != 0)
  1682. putchar(c1);
  1683. }
  1684. int column = 0;
  1685. void count()
  1686. {
  1687. int i;
  1688. for (i = 0; yytext[i] != '\0'; i++)
  1689. if (yytext[i] == '\n')
  1690. column = 0;
  1691. else if (yytext[i] == '\t')
  1692. column += 8 - (column % 8);
  1693. else
  1694. column++;
  1695. ECHO;
  1696. }
  1697. TOKEN *new_token(int type)
  1698. {
  1699. TOKEN *ans = (TOKEN*)malloc(sizeof(TOKEN));
  1700. ans->type = type;
  1701. return ans;
  1702. }
  1703. TOKEN *make_string(char *s)
  1704. {
  1705. TOKEN *ans = new_token(STRING_LITERAL);
  1706. int len = strlen(s);
  1707. ans->lexeme = (char*)calloc(1, len-1);
  1708. strncpy(ans->lexeme, s+1, len-2);
  1709. return ans;
  1710. }
  1711. TOKEN *make_int(char *s)
  1712. {
  1713. int n = *s!='\'' ? atoi(s) : *(s+1);
  1714. TOKEN *ans = new_token(CONSTANT);
  1715. ans->value = n;
  1716. asprintf(&ans->lexeme, "%d", n);
  1717. return ans;
  1718. }