Year 2 compilers coureswork

lex.yy.c 43KB

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