lexer.cc 57 KB

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