lexer.cc 56 KB

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