Year 2 compilers coureswork

lex.yy.c 51KB

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