home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / cplus / 13014 < prev    next >
Encoding:
Text File  |  1992-08-29  |  17.1 KB  |  720 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!rpi!batcomputer!cornell!moudgill
  3. From: moudgill@cs.cornell.edu ( Mayan Moudgill)
  4. Subject: Flex++
  5. Message-ID: <1992Aug28.140335.7118@cs.cornell.edu>
  6. Organization: Cornell Univ. CS Dept, Ithaca NY 14853
  7. Date: Fri, 28 Aug 1992 14:03:35 GMT
  8. Lines: 710
  9.  
  10. I've modified the flex skeleton so that it uses the following features of C++
  11.    1] C++ iostreams
  12.    2] new and delete
  13.    3] made yy_buffer_state into a ``class''.
  14.  
  15. I've also mucked around with some other stuff in the process, so there's
  16. no guarantee that it will work on existing flex inputs which try to add
  17. modify some #defines etc.
  18.  
  19. Has anyone else done a full conversion?
  20. ------------------------ cut here---------------------------------------
  21.  
  22. /* A lexical scanner generated by flex */
  23.  
  24. /* scanner skeleton version:
  25.  * $Header: /usr/fsys/odin/a/vern/flex/RCS/flex.skel,v 2.10 90/03/27 12:03:55 vern Exp $
  26.  */
  27.  
  28. #define FLEX_SCANNER
  29.  
  30. #include <iostream.h>
  31. extern istream * yyin;
  32. extern ostream * yyout;
  33.  
  34.  
  35. #include <stdlib.h>
  36. #include <osfcn.h>
  37.  
  38. /* use prototypes in function declarations */
  39. #define YY_USE_PROTOS
  40.  
  41. /* the "const" storage-class-modifier is valid */
  42. #define YY_USE_CONST
  43.  
  44.  
  45.  
  46. /* amount of stuff to slurp up with each read */
  47. #ifndef YY_READ_BUF_SIZE
  48. #define YY_READ_BUF_SIZE 8192
  49. #endif
  50.  
  51. /* returned upon end-of-file */
  52. #define YY_END_TOK 0
  53.  
  54. /* copy whatever the last rule matched to the standard output */
  55.  
  56. /* cast to (char *) is because for 8-bit chars, yytext is (unsigned char *) */
  57. /* this used to be an fputs(), but since the string might contain NUL's,
  58.  * we now use fwrite()
  59.  */
  60. #define ECHO (yyout->write(yytext, yyleng))
  61.  
  62. /* report a fatal error */
  63. inline void YY_FATAL_ERROR(char * msg)
  64. {
  65.    cerr << msg << "\n";
  66.    exit(1);
  67. }
  68.  
  69. /* gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
  70.  * is returned in "result".
  71.  */
  72. #define YY_NULL 0
  73. inline void YY_INPUT(char * buf, int& result, int max_size)
  74. {
  75.    if( yyin->eof() || yyin->fail() ) {
  76.      result = YY_NULL;
  77.    }
  78.    else {
  79.      yyin->read(buf, max_size);
  80.      result = yyin->gcount();
  81.      if( yyin->bad() ) {
  82.      YY_FATAL_ERROR( "read() in flex scanner failed" );
  83.      }
  84.    }
  85. }
  86.  
  87. /* no semi-colon after return; correct usage is to write "yyterminate();" -
  88.  * we don't want an extra ';' after the "return" because that will cause
  89.  * some compilers to complain about unreachable statements.
  90.  */
  91. #define yyterminate() return ( YY_NULL )
  92.  
  93. /* default yywrap function - always treat EOF as an EOF */
  94. #define yywrap() 1
  95.  
  96. /* enter a start condition.  This macro really ought to take a parameter,
  97.  * but we do it the disgusting crufty way forced on us by the ()-less
  98.  * definition of BEGIN
  99.  */
  100. #define BEGIN yy_start = 1 + 2 *
  101.  
  102. /* action number for EOF rule of a given start state */
  103. #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
  104.  
  105. /* special action meaning "start processing a new file" */
  106. #define YY_NEW_FILE { \
  107.    yy_current_buffer->yy_init_buffer( yyin ); \
  108.    yy_load_buffer_state(); \
  109. }
  110.  
  111. /* default declaration of generated scanner - a define so the user can
  112.  * easily add parameters
  113.  */
  114. #define YY_DECL int yylex ( void ) 
  115.  
  116. /* code executed at the end of each rule */
  117. #define YY_BREAK break;
  118.  
  119. #define YY_END_OF_BUFFER_CHAR 0
  120.  
  121. #ifndef YY_BUF_SIZE
  122. #define YY_BUF_SIZE (YY_READ_BUF_SIZE * 2) /* size of default input buffer */
  123. #endif
  124.  
  125. typedef struct yy_buffer_state *YY_BUFFER_STATE;
  126.  
  127. %% section 1 definitions go here
  128.  
  129. /* done after the current pattern has been matched and before the
  130.  * corresponding action - sets up yytext
  131.  */
  132. #define YY_DO_BEFORE_ACTION \
  133.     yytext = yy_bp; \
  134. %% code to fiddle yytext and yyleng for yymore() goes here
  135.     yy_hold_char = *yy_cp; \
  136.     *yy_cp = '\0'; \
  137.     yy_c_buf_p = yy_cp;
  138.  
  139. #define EOB_ACT_CONTINUE_SCAN 0
  140. #define EOB_ACT_END_OF_FILE 1
  141. #define EOB_ACT_LAST_MATCH 2
  142.  
  143. /* return all but the first 'n' matched characters back to the input stream */
  144. #define yyless(n) \
  145.     { \
  146.     /* undo effects of setting up yytext */ \
  147.     *yy_cp = yy_hold_char; \
  148.     yy_c_buf_p = yy_cp = yy_bp + n; \
  149.     YY_DO_BEFORE_ACTION; /* set up yytext again */ \
  150.     }
  151.  
  152. #define unput(c) yyunput( c, yytext )
  153.  
  154.  
  155. struct yy_buffer_state
  156.    {
  157.    istream * yy_input_file;
  158.  
  159.    YY_CHAR *yy_ch_buf;        /* input buffer */
  160.    YY_CHAR *yy_buf_pos;    /* current position in input buffer */
  161.  
  162.    /* size of input buffer in bytes, not including room for EOB characters*/
  163.    int yy_buf_size;    
  164.  
  165.    /* number of characters read into yy_ch_buf, not including EOB characters */
  166.    int yy_n_chars;
  167.  
  168.    int yy_eof_status;        /* whether we've seen an EOF on this buffer */
  169. #define EOF_NOT_SEEN 0
  170.    /* "pending" happens when the EOF has been seen but there's still
  171.     * some text process
  172.     */
  173. #define EOF_PENDING 1
  174. #define EOF_DONE 2
  175.    
  176.        yy_buffer_state(istream * , int );
  177.        ~yy_buffer_state();
  178.    void    yy_init_buffer(istream *);
  179.    };
  180.  
  181. static YY_BUFFER_STATE yy_current_buffer;
  182.  
  183. /* we provide macros for accessing buffer states in case in the
  184.  * future we want to put the buffer states in a more general
  185.  * "scanner state"
  186.  */
  187. #define YY_CURRENT_BUFFER yy_current_buffer
  188.  
  189.  
  190. /* yy_hold_char holds the character lost when yytext is formed */
  191. static YY_CHAR yy_hold_char;
  192.  
  193. static int yy_n_chars;        /* number of characters read into yy_ch_buf */
  194.  
  195.  
  196.  
  197. #ifndef YY_USER_ACTION
  198. #define YY_USER_ACTION
  199. #endif
  200.  
  201. extern YY_CHAR *yytext;
  202. extern int yyleng;
  203. extern istream * yyin;
  204. extern ostream * yyout;
  205.  
  206. YY_CHAR *yytext;
  207. int yyleng;
  208.  
  209. istream * yyin = 0;
  210. ostream * yyout =  0;
  211.  
  212. %% data tables for the DFA go here
  213.  
  214. /* these variables are all declared out here so that section 3 code can
  215.  * manipulate them
  216.  */
  217. /* points to current character in buffer */
  218. static YY_CHAR *yy_c_buf_p = (YY_CHAR *) 0;
  219. static int yy_init = 1;        /* whether we need to initialize */
  220. static int yy_start = 0;    /* start state number */
  221.  
  222. static yy_state_type yy_get_previous_state ( void );
  223. static yy_state_type yy_try_NUL_trans ( yy_state_type current_state );
  224. static int yy_get_next_buffer ( void );
  225. static void yyunput ( YY_CHAR c, YY_CHAR *buf_ptr );
  226. void yyrestart ( istream * input_file );
  227. void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer );
  228. void yy_load_buffer_state ( void );
  229. //CC YY_BUFFER_STATE yy_create_buffer ( istream * file, int size );
  230. //CC void yy_delete_buffer ( YY_BUFFER_STATE b );
  231. //CC void yy_init_buffer ( YY_BUFFER_STATE b, istream * file );
  232.  
  233. #ifdef __cplusplus
  234. static int yyinput ( void );
  235. #else
  236. static int input ( void );
  237. #endif
  238.  
  239. YY_DECL
  240.    {
  241.    register yy_state_type yy_current_state;
  242.    register YY_CHAR *yy_cp, *yy_bp;
  243.    register int yy_act;
  244.  
  245. %% user's declarations go here
  246.  
  247.    if ( yy_init )
  248.     {
  249.     if ( ! yy_start )
  250.        yy_start = 1;    /* first start state */
  251.  
  252.     if ( ! yyin )
  253.        yyin = &cin;
  254.  
  255.     if ( ! yyout )
  256.        yyout = &cout;
  257.  
  258.      if ( yy_current_buffer ) {
  259.         yy_current_buffer->yy_init_buffer( yyin );
  260.      }
  261.     else
  262. //CC       yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
  263.        yy_current_buffer = new yy_buffer_state( yyin, YY_BUF_SIZE );
  264.  
  265.     yy_load_buffer_state();
  266.  
  267.     yy_init = 0;
  268.     }
  269.  
  270.    while ( 1 )        /* loops until end-of-file is reached */
  271.     {
  272. %% yymore()-related code goes here
  273.     yy_cp = yy_c_buf_p;
  274.  
  275.     /* support of yytext */
  276.     *yy_cp = yy_hold_char;
  277.  
  278.     /* yy_bp points to the position in yy_ch_buf of the start of the
  279.      * current run.
  280.      */
  281.     yy_bp = yy_cp;
  282.  
  283. %% code to set up and find next match goes here
  284.  
  285. yy_find_action:
  286. %% code to find the action number goes here
  287.  
  288.     YY_DO_BEFORE_ACTION;
  289.     YY_USER_ACTION;
  290.  
  291. do_action:    /* this label is used only to access EOF actions */
  292.  
  293. %% debug code goes here
  294.  
  295.     switch ( yy_act )
  296.        {
  297. %% actions go here
  298.  
  299.        case YY_END_OF_BUFFER:
  300.         {
  301.         /* amount of text matched not including the EOB char */
  302.         int yy_amount_of_matched_text = yy_cp - yytext - 1;
  303.  
  304.         /* undo the effects of YY_DO_BEFORE_ACTION */
  305.         *yy_cp = yy_hold_char;
  306.  
  307.         /* note that here we test for yy_c_buf_p "<=" to the position
  308.          * of the first EOB in the buffer, since yy_c_buf_p will
  309.          * already have been incremented past the NUL character
  310.          * (since all states make transitions on EOB to the end-
  311.          * of-buffer state).  Contrast this with the test in yyinput().
  312.          */
  313.         if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
  314.            /* this was really a NUL */
  315.            {
  316.            yy_state_type yy_next_state;
  317.  
  318.            yy_c_buf_p = yytext + yy_amount_of_matched_text;
  319.  
  320.            yy_current_state = yy_get_previous_state();
  321.  
  322.            /* okay, we're now positioned to make the
  323.             * NUL transition.  We couldn't have
  324.             * yy_get_previous_state() go ahead and do it
  325.             * for us because it doesn't know how to deal
  326.             * with the possibility of jamming (and we
  327.             * don't want to build jamming into it because
  328.             * then it will run more slowly)
  329.             */
  330.  
  331.            yy_next_state = yy_try_NUL_trans( yy_current_state );
  332.  
  333.            yy_bp = yytext + YY_MORE_ADJ;
  334.  
  335.            if ( yy_next_state )
  336.             {
  337.             /* consume the NUL */
  338.             yy_cp = ++yy_c_buf_p;
  339.             yy_current_state = yy_next_state;
  340.             goto yy_match;
  341.             }
  342.  
  343.            else
  344.             {
  345. %% code to do backtracking for compressed tables and set up yy_cp goes here
  346.             goto yy_find_action;
  347.             }
  348.            }
  349.  
  350.         else switch ( yy_get_next_buffer() )
  351.            {
  352.            case EOB_ACT_END_OF_FILE:
  353.             {
  354.             if ( yywrap() )
  355.                {
  356.                /* note: because we've taken care in
  357.                 * yy_get_next_buffer() to have set up yytext,
  358.                 * we can now set up yy_c_buf_p so that if some
  359.                 * total hoser (like flex itself) wants
  360.                 * to call the scanner after we return the
  361.                 * YY_NULL, it'll still work - another YY_NULL
  362.                 * will get returned.
  363.                 */
  364.                yy_c_buf_p = yytext + YY_MORE_ADJ;
  365.  
  366.                yy_act = YY_STATE_EOF((yy_start - 1) / 2);
  367.                goto do_action;
  368.                }
  369.  
  370.             else
  371.                YY_NEW_FILE;
  372.             }
  373.             break;
  374.  
  375.            case EOB_ACT_CONTINUE_SCAN:
  376.             yy_c_buf_p = yytext + yy_amount_of_matched_text;
  377.  
  378.             yy_current_state = yy_get_previous_state();
  379.  
  380.             yy_cp = yy_c_buf_p;
  381.             yy_bp = yytext + YY_MORE_ADJ;
  382.             goto yy_match;
  383.  
  384.            case EOB_ACT_LAST_MATCH:
  385.             yy_c_buf_p =
  386.                &yy_current_buffer->yy_ch_buf[yy_n_chars];
  387.  
  388.             yy_current_state = yy_get_previous_state();
  389.  
  390.             yy_cp = yy_c_buf_p;
  391.             yy_bp = yytext + YY_MORE_ADJ;
  392.             goto yy_find_action;
  393.            }
  394.         break;
  395.         }
  396.  
  397.        default:
  398. #ifdef FLEX_DEBUG
  399.         printf( "action # %d\n", yy_act );
  400. #endif
  401.         YY_FATAL_ERROR(
  402.             "fatal flex scanner internal error--no action found" );
  403.        }
  404.     }
  405.    }
  406.  
  407.  
  408. /* yy_get_next_buffer - try to read in a new buffer
  409.  *
  410.  * synopsis
  411.  *    int yy_get_next_buffer();
  412.  *    
  413.  * returns a code representing an action
  414.  *    EOB_ACT_LAST_MATCH - 
  415.  *    EOB_ACT_CONTINUE_SCAN - continue scanning from current position
  416.  *    EOB_ACT_END_OF_FILE - end of file
  417.  */
  418.  
  419. static int yy_get_next_buffer()
  420.  
  421.    {
  422.    register YY_CHAR *dest = yy_current_buffer->yy_ch_buf;
  423.    register YY_CHAR *source = yytext - 1; /* copy prev. char, too */
  424.    register int number_to_move, i;
  425.    int ret_val;
  426.  
  427.    if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
  428.     YY_FATAL_ERROR(
  429.         "fatal flex scanner internal error--end of buffer missed" );
  430.  
  431.    /* try to read more data */
  432.  
  433.    /* first move last chars to start of buffer */
  434.    number_to_move = yy_c_buf_p - yytext;
  435.  
  436.    for ( i = 0; i < number_to_move; ++i )
  437.     *(dest++) = *(source++);
  438.  
  439.    if ( yy_current_buffer->yy_eof_status != EOF_NOT_SEEN )
  440.     /* don't do the read, it's not guaranteed to return an EOF,
  441.      * just force an EOF
  442.      */
  443.     yy_n_chars = 0;
  444.  
  445.    else
  446.     {
  447.     int num_to_read = yy_current_buffer->yy_buf_size - number_to_move - 1;
  448.  
  449.     if ( num_to_read > YY_READ_BUF_SIZE )
  450.        num_to_read = YY_READ_BUF_SIZE;
  451.  
  452.     else if ( num_to_read <= 0 )
  453.        YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" );
  454.  
  455.     /* read in more data */
  456.     YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
  457.           yy_n_chars, num_to_read );
  458.     }
  459.  
  460.    if ( yy_n_chars == 0 )
  461.     {
  462.     if ( number_to_move == 1 )
  463.        {
  464.        ret_val = EOB_ACT_END_OF_FILE;
  465.        yy_current_buffer->yy_eof_status = EOF_DONE;
  466.        }
  467.  
  468.     else
  469.        {
  470.        ret_val = EOB_ACT_LAST_MATCH;
  471.        yy_current_buffer->yy_eof_status = EOF_PENDING;
  472.        }
  473.     }
  474.  
  475.    else
  476.     ret_val = EOB_ACT_CONTINUE_SCAN;
  477.  
  478.    yy_n_chars += number_to_move;
  479.    yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
  480.    yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
  481.  
  482.    /* yytext begins at the second character in yy_ch_buf; the first
  483.     * character is the one which preceded it before reading in the latest
  484.     * buffer; it needs to be kept around in case it's a newline, so
  485.     * yy_get_previous_state() will have with '^' rules active
  486.     */
  487.  
  488.    yytext = &yy_current_buffer->yy_ch_buf[1];
  489.  
  490.    return ( ret_val );
  491.    }
  492.  
  493.  
  494. /* yy_get_previous_state - get the state just before the EOB char was reached
  495.  *
  496.  * synopsis
  497.  *    yy_state_type yy_get_previous_state();
  498.  */
  499.  
  500. static yy_state_type yy_get_previous_state()
  501.  
  502.    {
  503.    register yy_state_type yy_current_state;
  504.    register YY_CHAR *yy_cp;
  505.  
  506. %% code to get the start state into yy_current_state goes here
  507.  
  508.    for ( yy_cp = yytext + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
  509.     {
  510. %% code to find the next state goes here
  511.     }
  512.  
  513.    return ( yy_current_state );
  514.    }
  515.  
  516.  
  517. /* yy_try_NUL_trans - try to make a transition on the NUL character
  518.  *
  519.  * synopsis
  520.  *    next_state = yy_try_NUL_trans( current_state );
  521.  */
  522.  
  523. static yy_state_type yy_try_NUL_trans( register yy_state_type yy_current_state )
  524.    {
  525.    register int yy_is_jam;
  526. %% code to find the next state, and perhaps do backtracking, goes here
  527.  
  528.    return ( yy_is_jam ? 0 : yy_current_state );
  529.    }
  530.  
  531.  
  532. static void yyunput( YY_CHAR c, register YY_CHAR *yy_bp )
  533.    {
  534.    register YY_CHAR *yy_cp = yy_c_buf_p;
  535.  
  536.    /* undo effects of setting up yytext */
  537.    *yy_cp = yy_hold_char;
  538.  
  539.    if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
  540.     { /* need to shift things up to make room */
  541.     register int number_to_move = yy_n_chars + 2; /* +2 for EOB chars */
  542.     register YY_CHAR *dest =
  543.        &yy_current_buffer->yy_ch_buf[yy_current_buffer->yy_buf_size + 2];
  544.     register YY_CHAR *source =
  545.        &yy_current_buffer->yy_ch_buf[number_to_move];
  546.  
  547.     while ( source > yy_current_buffer->yy_ch_buf )
  548.        *--dest = *--source;
  549.  
  550.     yy_cp += dest - source;
  551.     yy_bp += dest - source;
  552.     yy_n_chars = yy_current_buffer->yy_buf_size;
  553.  
  554.     if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
  555.        YY_FATAL_ERROR( "flex scanner push-back overflow" );
  556.     }
  557.  
  558.    if ( yy_cp > yy_bp && yy_cp[-1] == '\n' )
  559.     yy_cp[-2] = '\n';
  560.  
  561.    *--yy_cp = c;
  562.  
  563.    /* note: the formal parameter *must* be called "yy_bp" for this
  564.     *      macro to now work correctly
  565.     */
  566.    YY_DO_BEFORE_ACTION; /* set up yytext again */
  567.    }
  568.  
  569.  
  570. #ifdef __cplusplus
  571. static int yyinput()
  572. #else
  573. static int input()
  574. #endif
  575.  
  576.    {
  577.    int c;
  578.    YY_CHAR *yy_cp = yy_c_buf_p;
  579.  
  580.    *yy_cp = yy_hold_char;
  581.  
  582.    if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
  583.     {
  584.     /* yy_c_buf_p now points to the character we want to return.
  585.      * If this occurs *before* the EOB characters, then it's a
  586.      * valid NUL; if not, then we've hit the end of the buffer.
  587.      */
  588.     if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
  589.        /* this was really a NUL */
  590.        *yy_c_buf_p = '\0';
  591.  
  592.     else
  593.        { /* need more input */
  594.        yytext = yy_c_buf_p;
  595.        ++yy_c_buf_p;
  596.  
  597.        switch ( yy_get_next_buffer() )
  598.         {
  599.         case EOB_ACT_END_OF_FILE:
  600.            {
  601.            if ( yywrap() )
  602.             {
  603.             yy_c_buf_p = yytext + YY_MORE_ADJ;
  604.             return ( EOF );
  605.             }
  606.  
  607.            YY_NEW_FILE;
  608.  
  609. #ifdef __cplusplus
  610.            return ( yyinput() );
  611. #else
  612.            return ( input() );
  613. #endif
  614.            }
  615.            break;
  616.  
  617.         case EOB_ACT_CONTINUE_SCAN:
  618.            yy_c_buf_p = yytext + YY_MORE_ADJ;
  619.            break;
  620.  
  621.         case EOB_ACT_LAST_MATCH:
  622. #ifdef __cplusplus
  623.            YY_FATAL_ERROR( "unexpected last match in yyinput()" );
  624. #else
  625.            YY_FATAL_ERROR( "unexpected last match in input()" );
  626. #endif
  627.         }
  628.        }
  629.     }
  630.  
  631.    c = *yy_c_buf_p;
  632.    yy_hold_char = *++yy_c_buf_p;
  633.  
  634.    return ( c );
  635.    }
  636.  
  637.  
  638. void yyrestart( istream * input_file )
  639. {
  640.    yy_current_buffer->yy_init_buffer( input_file );
  641.    yy_load_buffer_state();
  642. }
  643.  
  644.  
  645. void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
  646.    {
  647.    if ( yy_current_buffer == new_buffer )
  648.     return;
  649.  
  650.    if ( yy_current_buffer )
  651.     {
  652.     /* flush out information for old buffer */
  653.     *yy_c_buf_p = yy_hold_char;
  654.     yy_current_buffer->yy_buf_pos = yy_c_buf_p;
  655.     yy_current_buffer->yy_n_chars = yy_n_chars;
  656.     }
  657.  
  658.    yy_current_buffer = new_buffer;
  659.    yy_load_buffer_state();
  660.    }
  661.  
  662.  
  663. void yy_load_buffer_state( void )
  664. {
  665.    yy_n_chars = yy_current_buffer->yy_n_chars;
  666.    yytext = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
  667.    yyin = yy_current_buffer->yy_input_file;
  668.    yy_hold_char = *yy_c_buf_p;
  669. }
  670.  
  671.  
  672. yy_buffer_state::yy_buffer_state( istream * file, int size )
  673. : yy_buf_size(size)
  674. {
  675. //CC  if ( ! b )
  676. //CC       YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
  677.  
  678.    /* yy_ch_buf has to be 2 characters longer than the size given because
  679.     * we need to put in 2 end-of-buffer characters.
  680.     */
  681.    yy_ch_buf = new YY_CHAR [yy_buf_size + 2];
  682.  
  683. //CC   if ( !yy_ch_buf )
  684. //CC    YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
  685.  
  686.    yy_init_buffer( file );
  687. }
  688.  
  689.  
  690. yy_buffer_state::~yy_buffer_state()
  691. {
  692.    if( this == yy_current_buffer ) {
  693.       yy_current_buffer = 0;
  694.    }
  695.    delete[] yy_ch_buf;
  696. }
  697.  
  698. void yy_buffer_state::yy_init_buffer( istream *file )
  699. {
  700.    yy_input_file = file;
  701.  
  702.    /* we put in the '\n' and start reading from [1] so that an
  703.     * initial match-at-newline will be true.
  704.     */
  705.  
  706.    yy_ch_buf[0] = '\n';
  707.    yy_n_chars = 1;
  708.  
  709.    /* we always need two end-of-buffer characters.  The first causes
  710.     * a transition to the end-of-buffer state.  The second causes
  711.     * a jam in that state.
  712.     */
  713.    yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
  714.    yy_ch_buf[2] = YY_END_OF_BUFFER_CHAR;
  715.  
  716.    yy_buf_pos = &yy_ch_buf[1];
  717.  
  718.    yy_eof_status = EOF_NOT_SEEN;
  719. }
  720.