⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 flexskel.cc

📁 C++版 词法分析、语法分析器
💻 CC
📖 第 1 页 / 共 2 页
字号:
/* A lexical scanner generated by flex */
/* scanner skeleton version:
 * $Header: c:\\program\040files\\development\\cvs\040repository/flex++/flexskel.cc,v 1.1.1.1 2002/04/13 06:01:32 Bear Exp $
 */
/* MODIFIED FOR C++ CLASS BY Alain Coetmeur: coetmeur(at)icdc.fr */
/* Note that (at) mean the 'at' symbol that I cannot write */
/* because it is expanded to the class name */
/* made at Informatique-CDC, Research&development department */
/* company from the Caisse Des Depots et Consignations */
/* institutional financial group  */

/* theses symbols are added before this file */
/* #define YY_CHAR 'unsigned char' if 8bit or 'char' if 7bit */
/* #define FLEX_DEBUG if debug mode */
#define FLEX_SCANNER
/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
#ifdef c_plusplus
#ifndef __cplusplus
#define __cplusplus
#endif
#endif
/* Old MSC, before c7 */
#ifdef MSDOS
#ifndef _MSDOS
#define _MSDOS
#endif
#endif
/* turboc */
#ifdef __MSDOS__
#ifndef _MSDOS
#define _MSDOS
#endif
#endif

#ifdef __cplusplus
#include <stdlib.h>
#define YY_USE_CONST
#define YY_USE_PROTOS
#ifndef YY_USE_CLASS
#define YY_USE_CLASS
#endif
#ifndef _MSDOS
#include <osfcn.h>
#endif
#else   /* ! __cplusplus */
#ifdef __STDC__
#ifdef __GNUC__
#include <stddef.h>
void *malloc( size_t );
void free( void* );
int read();
#else
#include <stdlib.h>
#endif  /* __GNUC__ */
#define YY_USE_PROTOS
#define YY_USE_CONST
#endif  /* __STDC__ */
#endif  /* ! __cplusplus */
#ifdef __TURBOC__
#define YY_USE_CONST
#endif
#include <stdio.h>


/*********************************************/
/* COMPILER DEPENDENT   MACROS               */
/*********************************************/
/* use prototypes in function declarations */
/* the "const" storage-class-modifier is valid */
#ifndef YY_USE_CONST
#define const
#endif
/* use prototypes in function declarations */
#ifndef YY_PROTO
#ifdef YY_USE_PROTOS
#define YY_PROTO(proto) proto
#else
#define YY_PROTO(proto) ()
#endif
#endif


/*********************/
/* parameters        */

/* amount of stuff to slurp up with each read */
#ifndef YY_READ_BUF_SIZE
#define YY_READ_BUF_SIZE 8192
#endif
/* size of default input buffer */
#ifndef YY_BUF_SIZE
#define YY_BUF_SIZE (YY_READ_BUF_SIZE * 2) 
#endif

/***********************************/
/* to be redefined for application */

/* returned upon end-of-file */
#define YY_END_TOK 0
/* no semi-colon after return; correct usage is to write "yyterminate();" -
 * we don't want an extra ';' after the "return" because that will cause
 * some compilers to complain about unreachable statements.
 */
#define yyterminate() return ( YY_NULL )

/* code executed at the end of each rule */
#define YY_BREAK break;

/* #define YY_USER_ACTION */
/* #define YY_USER_INIT */


#ifndef YY_USE_CLASS
/* copy whatever the last rule matched to the standard output */
/* cast to (char *) is because for 8-bit chars, yy___text is (unsigned char *) */
/* this used to be an fputs(), but since the string might contain NUL's,
 * we now use fwrite()
 */
#define ECHO (void) fwrite( (char *) yy___text, yy___leng, 1, yy___out )

/* gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
 * is returned in "result".
 */
#ifdef _MSDOS
#define YY_INPUT(buf,result,max_size) \
	if ( (result = fread(buf,1,max_size,yy___in)) < 0 ) \
	    YY_FATAL_ERROR( "fread() in flex scanner failed" );
#else
#define YY_INPUT(buf,result,max_size) \
	if ( (result = read( fileno(yy___in), (char *) buf, max_size )) < 0 ) \
	    YY_FATAL_ERROR( "read() in flex scanner failed" );

#endif
/* report a fatal error */

/* The funky do-while is used to turn this macro definition into
 * a single C statement (which needs a semi-colon terminator).
 * This avoids problems with code like:
 *
 *      if ( something_happens )
 *              YY_FATAL_ERROR( "oops, the something happened" );
 *      else
 *              everything_okay();
 *
 * Prior to using the do-while the compiler would get upset at the
 * "else" because it interpreted the "if" statement as being all
 * done when it reached the ';' after the YY_FATAL_ERROR() call.
 */

#define YY_FATAL_ERROR(msg) \
	do \
		{ \
		(void) fputs( msg, yy___stderr  ); \
		(void) putc( '\n', yy___stderr  ); \
		exit( 1 ); \
		} \
	while ( 0 )

/* default yywrap function - always treat EOF as an EOF */
#define yywrap() 1


/* default declaration of generated scanner - a define so the user can
 * easily add parameters
 */
#define YY_DECL int yylex YY_PROTO(( void )) 
#else 
/* c++ */
#define ECHO yy___echo()
#define YY_INPUT(buf,result,max_size) \
	if ( yy___input((char *)buf, result,max_size) < 0 ) \
	    YY_FATAL_ERROR( "YY_INPUT() in flex scanner failed" );

#define YY_FATAL_ERROR(msg) yy___fatal_error(msg)
#define yywrap() yy___wrap()

#endif
/***********************************/
/* not to be changed */
#define YY_NULL 0
#define YY_END_OF_BUFFER_CHAR 0
/* special action meaning "start processing a new file" */
#define YY_NEW_FILE yy___newfile 
/* enter a start condition.  This macro really ought to take a parameter,
 * but we do it the disgusting crufty way forced on us by the ()-less
 * definition of BEGIN
 */
#define BEGIN yy_start = 1 + 2 *

/* action number for EOF rule of a given start state */
#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)



%% section 1 definitions go here

#define yy___stderr YY_@_ERRFILE
#define yy___text YY_@_TEXT
#define yy___leng YY_@_LENG
#define yy___in YY_@_IN
#define yy___out YY_@_OUT
#define yy___newfile \
	do \
		{ \
		YY_@_INIT_BUFFER( YY_@_CURRENT_BUFFER, yy___in ); \
		YY_@_LOAD_BUFFER_STATE(); \
		} \
	while ( 0 )
#if YY_@_DEBUG != 0
#define yy___flex_debug YY_@_DEBUG_FLAG
#endif


#ifdef YY_USE_CLASS

#define yy___echo YY_@_ECHO
#define yy___input YY_@_INPUT
#define yy___fatal_error YY_@_FATAL_ERROR
#define yy___wrap YY_@_WRAP

#endif

/* done after the current pattern has been matched and before the
 * corresponding action - sets up yy___text
 */
#define YY_DO_BEFORE_ACTION \
	yy___text = yy_bp; \
%% code to fiddle yy___text and yy___leng for yymore() goes here
	yy_hold_char = *yy_cp; \
	*yy_cp = '\0'; \
	yy_c_buf_p = yy_cp;

#define EOB_ACT_CONTINUE_SCAN 0
#define EOB_ACT_END_OF_FILE 1
#define EOB_ACT_LAST_MATCH 2

/* return all but the first 'n' matched characters back to the input stream */
#define yyless(n) \
	do \
		{ \
		/* undo effects of setting up yy___text */ \
		*yy_cp = yy_hold_char; \
		yy_c_buf_p = yy_cp = yy_bp + n; \
		YY_DO_BEFORE_ACTION; /* set up yy___text again */ \
		} \
	while ( 0 )

#define unput(c) yyunput( c, yy___text )



struct yy_buffer_state
    {
    YY_@_IFILE  *yy_input_file;

    YY_@_CHAR *yy_ch_buf;               /* input buffer */
    YY_@_CHAR *yy_buf_pos;      /* current position in input buffer */

    /* size of input buffer in bytes, not including room for EOB characters */
    int yy_buf_size;    

    /* number of characters read into yy_ch_buf, not including EOB characters */
    int yy_n_chars;

    int yy_eof_status;          /* whether we've seen an EOF on this buffer */
#define EOF_NOT_SEEN 0
    /* "pending" happens when the EOF has been seen but there's still
     * some text process
     */
#define EOF_PENDING 1
#define EOF_DONE 2
    };

/* we provide macros for accessing buffer states in case in the
 * future we want to put the buffer states in a more general
 * "scanner state"
 */

#ifndef YY_USE_CLASS

#if YY_@_DEBUG != 0
int YY_@_DEBUG_FLAG=YY_@_DEBUG_INIT;
#endif
#define YY_CURRENT_BUFFER YY_@_CURRENT_BUFFER
static YY_BUFFER_STATE YY_@_CURRENT_BUFFER;
/* yy_hold_char holds the character lost when yy___text is formed */
static YY_@_CHAR yy_hold_char;

static int yy_n_chars;          /* number of characters read into yy_ch_buf */

/* GLOBAL */
YY_@_CHAR *yy___text;
int yy___leng;

YY_@_IFILE  *yy___in = (YY_@_IFILE  *) 0;
YY_@_OFILE *yy___out = (YY_@_OFILE  *) 0;

#ifdef __cplusplus
static int yyinput YY_PROTO(( void ));
#else
static int input YY_PROTO(( void ));
#endif
/* these variables are all declared out here so that section 3 code can
 * manipulate them
 */
/* points to current character in buffer */
static YY_@_CHAR *yy_c_buf_p = (YY_@_CHAR *) 0;
static int yy_init = 1;         /* whether we need to initialize */
static int yy_start = 0;        /* start state number */

/* flag which is used to allow yywrap()'s to do buffer switches
 * instead of setting up a fresh yy___in.  A bit of a hack ...
 */
static int yy_did_buffer_switch_on_eof;

static int yy_get_next_buffer YY_PROTO(( void ));
static void yyunput YY_PROTO(( YY_@_CHAR c, YY_@_CHAR *buf_ptr ));

#else
/* c++ */
#ifndef YY_@_ECHO_NOCODE
void YY_@_CLASS::yy___echo()
{YY_@_ECHO_CODE
}
#endif
#ifndef YY_@_INPUT_NOCODE
int  YY_@_CLASS::yy___input(char * buffer,int &result,int max_size)
{YY_@_INPUT_CODE
}
#endif
#ifndef YY_@_FATAL_ERROR_NOCODE
void YY_@_CLASS::yy___fatal_error(char *msg)
{YY_@_FATAL_ERROR_CODE
}
#endif
#ifndef YY_@_WRAP_NOCODE
int  YY_@_CLASS::yy___wrap()
{YY_@_WRAP_CODE
}
#endif
void YY_@_CLASS::yy_initialize()
{
 yy___in=0;yy___out=0;yy_init = 1;
 yy_start=0;
 yy___text=0;yy___leng=0;
 YY_@_CURRENT_BUFFER=0;
 yy_did_buffer_switch_on_eof=0;
 yy_c_buf_p=0;yy_hold_char=0;yy_n_chars=0;
#if YY_@_DEBUG != 0
 YY_@_DEBUG_FLAG=YY_@_DEBUG_INIT;
#endif
}

YY_@_CLASS::YY_@_CLASS(YY_@_CONSTRUCTOR_PARAM) YY_@_CONSTRUCTOR_INIT
{yy_initialize();
 YY_@_CONSTRUCTOR_CODE;
}
YY_@_CLASS::~YY_@_CLASS() 
{YY_@_DESTRUCTOR_CODE;
 if(YY_@_CURRENT_BUFFER)
  YY_@_DELETE_BUFFER(YY_@_CURRENT_BUFFER);
}

#endif


#ifndef YY_USER_ACTION
#define YY_USER_ACTION
#endif

#ifndef YY_USER_INIT
#define YY_USER_INIT
#endif

%% data tables for the DFA go here
#ifndef YY_USE_CLASS
static yy_state_type yy_get_previous_state YY_PROTO(( void ));
static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
#else
#define yy_get_previous_state() ((yy_state_type)(yy_get_previous_state_()))
#define yy_try_NUL_trans(c) ((yy_state_type)(yy_try_NUL_trans_(c)))
#endif

#ifndef YY_USE_CLASS
#ifdef YY_@_LEX_DEFINED
YY_@_LEX_RETURN YY_@_LEX ( YY_@_LEX_PARAM )
YY_@_LEX_PARAM_DEF
#else
YY_DECL
#endif
#else
YY_@_LEX_RETURN YY_@_CLASS::YY_@_LEX ( YY_@_LEX_PARAM)

#endif
    {
    register yy_state_type yy_current_state;
    register YY_@_CHAR *yy_cp, *yy_bp;
    register int yy_act;

%% user's declarations go here

    if ( yy_init )
	{
	 
	 {
	 YY_USER_INIT;
	 }
	if ( ! yy_start )
	    yy_start = 1;       /* first start state */

	if ( ! yy___in )
	    yy___in = YY_@_IFILE_DEFAULT;

	if ( ! yy___out )
	    yy___out = YY_@_OFILE_DEFAULT;

	if ( YY_@_CURRENT_BUFFER )
	    YY_@_INIT_BUFFER( YY_@_CURRENT_BUFFER, yy___in );
	else
	    YY_@_CURRENT_BUFFER = YY_@_CREATE_BUFFER( yy___in, YY_BUF_SIZE );

	YY_@_LOAD_BUFFER_STATE();
	yy_init=0;
	}

    while ( 1 )         /* loops until end-of-file is reached */
	{
%% yymore()-related code goes here
	yy_cp = yy_c_buf_p;

	/* support of yy___text */
	*yy_cp = yy_hold_char;

	/* yy_bp points to the position in yy_ch_buf of the start of the
	 * current run.
	 */
	yy_bp = yy_cp;

%% code to set up and find next match goes here

yy_find_action:
%% code to find the action number goes here

	YY_DO_BEFORE_ACTION;
	YY_USER_ACTION;

do_action:      /* this label is used only to access EOF actions */
#if YY_@_DEBUG != 0
	if ( yy___flex_debug )
		{
		if ( yy_act == 0 )
#ifndef YY_@_IOSTREAM
			fprintf( yy___stderr , "--scanner backtracking\n" );
#else
			yy___stderr <<"--scanner backtracking"<<endl;
#endif
		else if ( yy_act < YY_END_OF_BUFFER -1 )
#ifndef YY_@_IOSTREAM
			fprintf( yy___stderr , 
			 "--accepting rule at line %d (\"%s\")\n",
			 yy_rule_linenum[yy_act], yy___text );
#else
			yy___stderr <<"--accepting rule at line "
                          <<(int)yy_rule_linenum[yy_act]
                          <<" (\""<<(char *)yy___text<<"\")"<<endl;
#endif
		else if ( yy_act == YY_END_OF_BUFFER -1 )
#ifndef YY_@_IOSTREAM
			fprintf( yy___stderr , 
			 "--accepting default rule (\"%s\")\n",
			 yy___text );
#else
			yy___stderr <<"--accepting default rule"
                          <<" (\""<<(char *)yy___text<<"\")"<<endl;
#endif
		else if ( yy_act == YY_END_OF_BUFFER )
#ifndef YY_@_IOSTREAM
			fprintf( yy___stderr , "--(end of buffer or a NUL)\n" );
#else
			yy___stderr <<"--(end of buffer or a NUL)"<<endl;
#endif
		else
#ifndef YY_@_IOSTREAM
			fprintf( yy___stderr , "--EOF\n" );
#else
			yy___stderr <<"--EOF"<<endl;
#endif
		}
#endif
	switch ( yy_act )
	    {
%% actions go here

	    case YY_END_OF_BUFFER:
		{
		/* amount of text matched not including the EOB char */
		int yy_amount_of_matched_text = yy_cp - yy___text - 1;

		/* undo the effects of YY_DO_BEFORE_ACTION */
		*yy_cp = yy_hold_char;

		/* note that here we test for yy_c_buf_p "<=" to the position
		 * of the first EOB in the buffer, since yy_c_buf_p will
		 * already have been incremented past the NUL character
		 * (since all states make transitions on EOB to the end-
		 * of-buffer state).  Contrast this with the test in yyinput().
		 */
		if ( yy_c_buf_p <= &YY_@_CURRENT_BUFFER->yy_ch_buf[yy_n_chars] )
		    /* this was really a NUL */
		    {
		    yy_state_type yy_next_state;

		    yy_c_buf_p = yy___text + yy_amount_of_matched_text;

		    yy_current_state = yy_get_previous_state();

		    /* okay, we're now positioned to make the
		     * NUL transition.  We couldn't have
		     * yy_get_previous_state() go ahead and do it
		     * for us because it doesn't know how to deal
		     * with the possibility of jamming (and we
		     * don't want to build jamming into it because
		     * then it will run more slowly)
		     */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -