home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / TOP / USR / LIB / flex.skel < prev   
Text File  |  2009-11-06  |  11KB  |  496 lines

  1. /* A lexical scanner generated by flex */
  2.  
  3. /* scanner skeleton version:
  4.  * $Header: flex.skel,v 2.0 89/06/20 15:49:46 vern Locked $
  5.  */
  6.  
  7. #include <stdio.h>
  8.  
  9. #define FLEX_SCANNER
  10.  
  11. /* amount of stuff to slurp up with each read */
  12. #ifndef YY_READ_BUF_SIZE
  13. #define YY_READ_BUF_SIZE 8192
  14. #endif
  15.  
  16. #ifndef YY_BUF_SIZE
  17. #define YY_BUF_SIZE (YY_READ_BUF_SIZE * 2) /* size of input buffer */
  18. #endif
  19.  
  20. /* returned upon end-of-file */
  21. #define YY_END_TOK 0
  22.  
  23. /* copy whatever the last rule matched to the standard output */
  24.  
  25. #define ECHO fputs( yytext, yyout )
  26.  
  27. /* gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
  28.  * is returned in "result".
  29.  */
  30. #define YY_INPUT(buf,result,max_size) \
  31.     if ( (result = read( fileno(yyin), buf, max_size )) < 0 ) \
  32.         YY_FATAL_ERROR( "read() in flex scanner failed" );
  33. #define YY_NULL 0
  34. #define yyterminate() return ( YY_NULL )
  35.  
  36. /* report a fatal error */
  37. #define YY_FATAL_ERROR(msg) \
  38.     { \
  39.     fputs( msg, stderr ); \
  40.     putc( '\n', stderr ); \
  41.     exit( 1 ); \
  42.     }
  43.  
  44. /* default yywrap function - always treat EOF as an EOF */
  45. #define yywrap() 1
  46.  
  47. /* enter a start condition.  This macro really ought to take a parameter,
  48.  * but we do it the disgusting crufty way forced on us by the ()-less
  49.  * definition of BEGIN
  50.  */
  51. #define BEGIN yy_start = 1 + 2 *
  52.  
  53. /* action number for EOF rule of a given start state */
  54. #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
  55.  
  56. /* special action meaning "start processing a new file" */
  57. #define YY_NEW_FILE goto new_file
  58.  
  59. /* default declaration of generated scanner - a define so the user can
  60.  * easily add parameters
  61.  */
  62. #ifdef __STDC__
  63. #define YY_DECL int yylex( void )
  64. #else
  65. #define YY_DECL int yylex()
  66. #endif
  67.  
  68. /* code executed at the end of each rule */
  69. #define YY_BREAK break;
  70.  
  71. #define YY_END_OF_BUFFER_CHAR 0
  72.  
  73. /* done after the current pattern has been matched and before the
  74.  * corresponding action - sets up yytext
  75.  */
  76. #define YY_DO_BEFORE_ACTION \
  77.     yytext = yy_bp; \
  78.     yy_hold_char = *yy_cp; \
  79.     *yy_cp = '\0'; \
  80.     yy_c_buf_p = yy_cp;
  81.  
  82. /* returns the length of the matched text */
  83. #define yyleng (yy_cp - yy_bp)
  84.  
  85. #define EOB_ACT_RESTART_SCAN 0
  86. #define EOB_ACT_END_OF_FILE 1
  87. #define EOB_ACT_LAST_MATCH 2
  88.  
  89. /* return all but the first 'n' matched characters back to the input stream */
  90. #define yyless(n) \
  91.     { \
  92.     *yy_cp = yy_hold_char; /* undo effects of setting up yytext */ \
  93.     yy_c_buf_p = yy_cp = yy_bp + n; \
  94.     YY_DO_BEFORE_ACTION; /* set up yytext again */ \
  95.     }
  96.  
  97. #define unput(c) yyunput( c, yy_bp )
  98.  
  99. #define YY_USER_ACTION
  100.  
  101. FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
  102. char *yytext;
  103.  
  104. #ifndef __STDC__
  105. #define const
  106. #endif
  107.  
  108. %% section 1 code and the data tables for the DFA go here
  109.  
  110. /* these variables are all declared out here so that section 3 code can
  111.  * manipulate them
  112.  */
  113. static char *yy_c_buf_p;    /* points to current character in buffer */
  114. static int yy_init = 1;        /* whether we need to initialize */
  115. static int yy_start = 0;    /* start state number */
  116.  
  117. /* true when we've seen an EOF for the current input file */
  118. static int yy_eof_has_been_seen;
  119.  
  120. static int yy_n_chars;        /* number of characters read into yy_ch_buf */
  121.  
  122. /* yy_ch_buf has to be 2 characters longer than YY_BUF_SIZE because we need
  123.  * to put in 2 end-of-buffer characters (this is explained where it is
  124.  * done) at the end of yy_ch_buf
  125.  */
  126. static char yy_ch_buf[YY_BUF_SIZE + 2];
  127.  
  128. /* yy_hold_char holds the character lost when yytext is formed */
  129. static char yy_hold_char;
  130.  
  131. static yy_state_type yy_last_accepting_state;
  132. static char *yy_last_accepting_cpos;
  133.  
  134. #ifdef __STDC__
  135. static yy_state_type yy_get_previous_state( void );
  136. static int yy_get_next_buffer( void );
  137. static void yyunput( int c, char *buf_ptr );
  138. static int input( void );
  139. static void yyrestart( FILE *input_file );
  140. #else
  141. static yy_state_type yy_get_previous_state();
  142. static int yy_get_next_buffer();
  143. static void yyunput();
  144. static int input();
  145. static void yyrestart();
  146. #endif
  147.  
  148. YY_DECL
  149.     {
  150.     register yy_state_type yy_current_state;
  151.     register char *yy_cp, *yy_bp;
  152.     register int yy_act;
  153.  
  154. %% user's declarations go here
  155.  
  156.     if ( yy_init )
  157.     {
  158.     if ( ! yy_start )
  159.         yy_start = 1;    /* first start state */
  160.  
  161.     if ( ! yyin )
  162.         yyin = stdin;
  163.  
  164.     if ( ! yyout )
  165.         yyout = stdout;
  166.  
  167. new_file:
  168.     /* this is where we enter upon encountering an end-of-file and
  169.      * yywrap() indicating that we should continue processing
  170.      */
  171.  
  172.     /* we put in the '\n' and start reading from [1] so that an
  173.      * initial match-at-newline will be true.
  174.      */
  175.  
  176.     yy_ch_buf[0] = '\n';
  177.     yy_n_chars = 1;
  178.  
  179.     /* we always need two end-of-buffer characters.  The first causes
  180.      * a transition to the end-of-buffer state.  The second causes
  181.      * a jam in that state.
  182.      */
  183.     yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
  184.     yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
  185.  
  186.     yy_eof_has_been_seen = 0;
  187.  
  188.     yytext = yy_c_buf_p = &yy_ch_buf[1];
  189.     yy_hold_char = *yy_c_buf_p;
  190.     yy_init = 0;
  191.     }
  192.  
  193.     while ( 1 )        /* loops until end-of-file is reached */
  194.     {
  195.     yy_cp = yy_c_buf_p;
  196.  
  197.     /* support of yytext */
  198.     *yy_cp = yy_hold_char;
  199.  
  200.     /* yy_bp points to the position in yy_ch_buf of the start of the
  201.      * current run.
  202.      */
  203. %% yymore()-related code goes here
  204.  
  205. %% code to set up and find next match goes here
  206.  
  207.     /* bogus while loop to let YY_BACK_TRACK, EOB_ACT_LAST_MATCH,
  208.      * and EOF actions branch here without introducing an optimizer-
  209.      * daunting goto
  210.      */
  211.     while ( 1 )
  212.         {
  213. %% code to find the action number goes here
  214.  
  215.         YY_DO_BEFORE_ACTION;
  216.         YY_USER_ACTION;
  217.  
  218. #ifdef FLEX_DEBUG
  219.         fprintf( stderr, "--accepting rule #%d (\"%s\")\n",
  220.              yy_act, yytext );
  221. #endif
  222.  
  223. do_action:    /* this label is used only to access EOF actions */
  224.         switch ( yy_act )
  225.         {
  226. %% actions go here
  227.  
  228.         case YY_END_OF_BUFFER:
  229.             /* undo the effects of YY_DO_BEFORE_ACTION */
  230.             *yy_cp = yy_hold_char;
  231.  
  232.             yytext = yy_bp;
  233.  
  234.             switch ( yy_get_next_buffer() )
  235.             {
  236.             case EOB_ACT_END_OF_FILE:
  237.                 {
  238.                 if ( yywrap() )
  239.                 {
  240.                 /* note: because we've taken care in
  241.                  * yy_get_next_buffer() to have set up yytext,
  242.                  * we can now set up yy_c_buf_p so that if some
  243.                  * total hoser (like flex itself) wants
  244.                  * to call the scanner after we return the
  245.                  * YY_NULL, it'll still work - another YY_NULL
  246.                  * will get returned.
  247.                  */
  248.                 yy_c_buf_p = yytext;
  249.  
  250.                 yy_act = YY_STATE_EOF((yy_start - 1) / 2);
  251.                 goto do_action;
  252.                 }
  253.  
  254.                 else
  255.                 YY_NEW_FILE;
  256.                 }
  257.                 break;
  258.  
  259.             case EOB_ACT_RESTART_SCAN:
  260.                 yy_c_buf_p = yytext;
  261.                 yy_hold_char = *yy_c_buf_p;
  262.                 break;
  263.  
  264.             case EOB_ACT_LAST_MATCH:
  265.                 yy_c_buf_p = &yy_ch_buf[yy_n_chars];
  266.  
  267.                 yy_current_state = yy_get_previous_state();
  268.  
  269.                 yy_cp = yy_c_buf_p;
  270.                 yy_bp = yytext;
  271.                 continue; /* go to "YY_DO_BEFORE_ACTION" */
  272.             }
  273.             break;
  274.  
  275.         default:
  276.             printf( "action # %d\n", yy_act );
  277.             YY_FATAL_ERROR( "fatal flex scanner internal error" );
  278.         }
  279.  
  280.         break; /* exit bogus while loop */
  281.         }
  282.     }
  283.     }
  284.  
  285.  
  286. /* yy_get_next_buffer - try to read in new buffer
  287.  *
  288.  * synopsis
  289.  *     int yy_get_next_buffer();
  290.  *     
  291.  * returns a code representing an action
  292.  *     EOB_ACT_LAST_MATCH - 
  293.  *     EOB_ACT_RESTART_SCAN - restart the scanner
  294.  *     EOB_ACT_END_OF_FILE - end of file
  295.  */
  296.  
  297. static int yy_get_next_buffer()
  298.  
  299.     {
  300.     register char *dest = yy_ch_buf;
  301.     register char *source = yytext - 1; /* copy prev. char, too */
  302.     register int number_to_move, i;
  303.     int ret_val;
  304.     
  305.     if ( yy_c_buf_p != &yy_ch_buf[yy_n_chars + 1] )
  306.     {
  307.     YY_FATAL_ERROR( "NULL in input" );
  308.     /*NOTREACHED*/
  309.     }
  310.  
  311.     /* try to read more data */
  312.  
  313.     /* first move last chars to start of buffer */
  314.     number_to_move = yy_c_buf_p - yytext;
  315.  
  316.     for ( i = 0; i < number_to_move; ++i )
  317.     *(dest++) = *(source++);
  318.  
  319.     if ( yy_eof_has_been_seen )
  320.     /* don't do the read, it's not guaranteed to return an EOF,
  321.      * just force an EOF
  322.      */
  323.     yy_n_chars = 0;
  324.  
  325.     else
  326.     {
  327.     int num_to_read = YY_BUF_SIZE - number_to_move - 1;
  328.  
  329.     if ( num_to_read > YY_READ_BUF_SIZE )
  330.         num_to_read = YY_READ_BUF_SIZE;
  331.  
  332.     /* read in more data */
  333.     YY_INPUT( (&yy_ch_buf[number_to_move]), yy_n_chars, num_to_read );
  334.     }
  335.  
  336.     if ( yy_n_chars == 0 )
  337.     {
  338.     if ( number_to_move == 1 )
  339.         ret_val = EOB_ACT_END_OF_FILE;
  340.     else
  341.         ret_val = EOB_ACT_LAST_MATCH;
  342.  
  343.     yy_eof_has_been_seen = 1;
  344.     }
  345.  
  346.     else
  347.     ret_val = EOB_ACT_RESTART_SCAN;
  348.  
  349.     yy_n_chars += number_to_move;
  350.     yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
  351.     yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
  352.  
  353.     /* yytext begins at the second character in
  354.      * yy_ch_buf; the first character is the one which
  355.      * preceded it before reading in the latest buffer;
  356.      * it needs to be kept around in case it's a
  357.      * newline, so yy_get_previous_state() will have
  358.      * with '^' rules active
  359.      */
  360.  
  361.     yytext = &yy_ch_buf[1];
  362.  
  363.     return ( ret_val );
  364.     }
  365.  
  366.  
  367. /* yy_get_previous_state - get the state just before the EOB char was reached
  368.  *
  369.  * synopsis
  370.  *     yy_state_type yy_get_previous_state();
  371.  */
  372.  
  373. static yy_state_type yy_get_previous_state()
  374.  
  375.     {
  376.     register yy_state_type yy_current_state;
  377.     register char *yy_cp;
  378.  
  379. %% code to get the start state into yy_current_state goes here
  380.  
  381.     for ( yy_cp = yytext; yy_cp < yy_c_buf_p; ++yy_cp )
  382.     {
  383. %% code to find the next state goes here
  384.     }
  385.  
  386.     return ( yy_current_state );
  387.     }
  388.  
  389.  
  390. #ifdef __STDC__
  391. static void yyunput( int c, register char *yy_bp )
  392. #else
  393. static void yyunput( c, yy_bp )
  394. int c;
  395. register char *yy_bp;
  396. #endif
  397.  
  398.     {
  399.     register char *yy_cp = yy_c_buf_p;
  400.  
  401.     *yy_cp = yy_hold_char; /* undo effects of setting up yytext */
  402.  
  403.     if ( yy_cp < yy_ch_buf + 2 )
  404.     { /* need to shift things up to make room */
  405.     register int number_to_move = yy_n_chars + 2; /* +2 for EOB chars */
  406.     register char *dest = &yy_ch_buf[YY_BUF_SIZE + 2];
  407.     register char *source = &yy_ch_buf[number_to_move];
  408.  
  409.     while ( source > yy_ch_buf )
  410.         *--dest = *--source;
  411.  
  412.     yy_cp += dest - source;
  413.     yy_bp += dest - source;
  414.  
  415.     if ( yy_cp < yy_ch_buf + 2 )
  416.         YY_FATAL_ERROR( "flex scanner push-back overflow" );
  417.     }
  418.  
  419.     if ( yy_cp > yy_bp && yy_cp[-1] == '\n' )
  420.     yy_cp[-2] = '\n';
  421.  
  422.     *--yy_cp = c;
  423.  
  424.     YY_DO_BEFORE_ACTION; /* set up yytext again */
  425.     }
  426.  
  427.  
  428. static int input()
  429.  
  430.     {
  431.     int c;
  432.     char *yy_cp = yy_c_buf_p;
  433.  
  434.     *yy_cp = yy_hold_char;
  435.  
  436.     if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
  437.     { /* need more input */
  438.     yytext = yy_c_buf_p;
  439.     ++yy_c_buf_p;
  440.  
  441.     switch ( yy_get_next_buffer() )
  442.         {
  443.         /* this code, unfortunately, is somewhat redundant with
  444.          * that above
  445.          */
  446.         case EOB_ACT_END_OF_FILE:
  447.         {
  448.         if ( yywrap() )
  449.             {
  450.             yy_c_buf_p = yytext;
  451.             return ( EOF );
  452.             }
  453.  
  454.         yy_ch_buf[0] = '\n';
  455.         yy_n_chars = 1;
  456.         yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
  457.         yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
  458.         yy_eof_has_been_seen = 0;
  459.         yytext = yy_c_buf_p = &yy_ch_buf[1];
  460.         yy_hold_char = *yy_c_buf_p;
  461.  
  462.         return ( input() );
  463.         }
  464.         break;
  465.  
  466.         case EOB_ACT_RESTART_SCAN:
  467.         yy_c_buf_p = yytext;
  468.         break;
  469.  
  470.         case EOB_ACT_LAST_MATCH:
  471.         YY_FATAL_ERROR( "unexpected last match in input()" );
  472.         }
  473.     }
  474.  
  475.     c = *yy_c_buf_p;
  476.     yy_hold_char = *++yy_c_buf_p;
  477.  
  478.     return ( c );
  479.     }
  480.  
  481.  
  482. #ifdef __STDC__
  483. static void yyrestart( FILE *input_file )
  484. #else
  485. static void yyrestart( input_file )
  486. FILE *input_file;
  487. #endif
  488.  
  489.     {
  490.     if ( yyin != stdin )
  491.     fclose( yyin );
  492.  
  493.     yyin = input_file;
  494.     yy_init = 1;
  495.     }
  496.