PageRenderTime 57ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/scripts/genksyms/lex.lex.c_shipped

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