C指针原理(10)

转自:http://blog.csdn.net/myhaspl/article/details/14228099

flex和bison编译系列


 Cygwin是一组工具,在WINDOWS操作系统下提供LINUX外观,让用户感觉在LINUX环境操作一样。Cygwin关键是cygwin1.dll库,它能模拟LINUX的API层,提供大量的linux API函数。

    但cygwin不能在WINDOWS下运行原生的LINUX程序,如果想在WINDOWS下运行,必须重新编译源代码。而原生 的windows程序也无法意识到自己是工作在一些UNIX机制下,比如说信号、伪终端等,你可以重新从源代码编译你的程序,以便利用Cygwin的提供的UNIX机制。 

安装好cygwin,同时下载flex和bison,如果安装时没有下载,可以再运行一次安装文件,选择install from local directory


安装完毕后进行测试


                 

1、打开cygwin,进入home目录,home目录在WINDOWS系统的cygwin安装目录映射为home目录。

2、首先,在home目录中新建文件夹,在文件夹中放置如下内容的test1.l

/*统计字数*/

%{

int chars=0;

int words=0;

int lines=0;

%}

%%

[a-zA-Z]+  {words++;chars+=strlen(yytext);}

\n  {chars++;lines++;}

.   {chars++;}

%%

main(int argc,char**argv)

{

   yylex();

   printf("%d%d%d\n",lines,words,chars);

}

然后调用flex生成词法分析器

 

Administrator@2012-20121224HD /home/flexlinux

$ cd /home

 

Administrator@2012-20121224HD /home

$ cd flexlinux

 

Administrator@2012-20121224HD /home/flexlinux

$ flex test1.l

 

Administrator@2012-20121224HD /home/flexlinux

$

可以看到目录中的lex.yy.c就是刚生成的C源码,可分析词法。

Administrator@2012-20121224HD /home/flexlinux

$ ls

lex.yy.c  test1.l

 

Administrator@2012-20121224HD /home/flexlinux

$

 flex自动生成了下面程序

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

编译该程序后,运行,统计出了行数、单词数、字符数。

Administrator@2012-20121224HD /home/flexlinux
$ gcc lex.yy.c -lfl


Administrator@2012-20121224HD /home/flexlinux
$ ./a
hello,world
myhaspl
2-3-20


Administrator@2012-20121224HD /home/flexlinux
$


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值