📄 lex.swf5.c
字号:
#include <math.h>#include <string.h>#include <stdlib.h>#include "compile.h"#include "actiontypes.h"#include "blocks/error.h"#include "swf5compiler.tab.h" /* defines token types */static int swf5debug;static const char *lexBuffer = NULL;static int lexBufferLen = 0;static int sLineNumber = 0, realLine = 0;static char msgbufs[2][1024] = { {0}, {0} }, *msgline = {0};static int column = 0, realColumn = 0, lastToken = 0;static void comment();static void comment1();static void count();static void countline();static void warning(char *msg);static int yy_first_time = 1;static int yy_new_state;#define YY_INPUT(buf,result,max_size) result=lexBufferInput(buf, max_size)#define YY_NO_UNISTD_H#define YY_USE_PROTOS/* thanks to the prolific and brilliant Raff: */static int lexBufferInput(char *buf, int max_size){ int l = lexBufferLen > max_size ? max_size : lexBufferLen; if (lexBufferLen <= 0) return YY_NULL; memcpy(buf, lexBuffer, l); lexBuffer += l; lexBufferLen -= l; return l;}static void unescape(char *buf){ char *r, *w; r=buf; // read w=buf; // write while (*r) { if ( *r == '\\' ) { r++; switch(*r) { case 'b' : *w = '\b'; break; case 'f' : *w = '\f'; break; case 'n' : *w = '\n'; break; case 'r' : *w = '\r'; break; case 't' : *w = '\t'; break; case 'x' : case 'u' : fprintf(stderr,"unsupported escape sequence\n"); break; default : *w = *r; break; } w++; r++; } else { *w++ = *r++; } } *w='\0';}void swf5ParseInit(const char *script, int debug, int version){ swf5restart(NULL); swf5debug = debug; lexBuffer = script; lexBufferLen = strlen(script); sLineNumber = 0; column = 0; msgline = msgbufs[0]; swfVersion = version;}int read_int (const char *text, YYSTYPE *num){ unsigned long i; i = strtoul (text, NULL, 0); if (i > 0x7FFFFFFF) { /* note: this catches ERANGE, too */ num->doubleVal = atof(swf5text); return DOUBLE; } num->intVal = i; return INTEGER;}#line 118 "./swf5compiler.flex" // forward declaration needed by the following function#ifndef YY_PROTO#ifdef YY_USE_PROTOS#define YY_PROTO(proto) proto#else#define YY_PROTO(proto) ()#endif#endif static void yyunput YY_PROTO(( int c, char *buf_ptr )); void do_unput5(const char c) { unput(c); }#line 1221 "lex.swf5.c"#define INITIAL 0#define STATE_ASM 1#define STATE_LEGACY 2#define STATE_PURE 3#ifndef YY_NO_UNISTD_H/* Special case for "unistd.h", since it is non-ANSI. We include it way * down here because we want the user's section 1 to have been scanned first. * The user has a chance to override it with an option. */#include <unistd.h>#endif#ifndef YY_EXTRA_TYPE#define YY_EXTRA_TYPE void *#endifstatic int yy_init_globals (void );/* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */int swf5lex_destroy (void );int swf5get_debug (void );void swf5set_debug (int debug_flag );YY_EXTRA_TYPE swf5get_extra (void );void swf5set_extra (YY_EXTRA_TYPE user_defined );FILE *swf5get_in (void );void swf5set_in (FILE * in_str );FILE *swf5get_out (void );void swf5set_out (FILE * out_str );int swf5get_leng (void );char *swf5get_text (void );int swf5get_lineno (void );void swf5set_lineno (int line_number );/* Macros after this point can all be overridden by user definitions in * section 1. */#ifndef YY_SKIP_YYWRAP#ifdef __cplusplusextern "C" int swf5wrap (void );#elseextern int swf5wrap (void );#endif#endif static void yyunput (int c,char *buf_ptr ); #ifndef yytext_ptrstatic void yy_flex_strncpy (char *,yyconst char *,int );#endif#ifdef YY_NEED_STRLENstatic int yy_flex_strlen (yyconst char * );#endif#ifndef YY_NO_INPUT#ifdef __cplusplusstatic int yyinput (void );#elsestatic int input (void );#endif#endif static int yy_start_stack_ptr = 0; static int yy_start_stack_depth = 0; static int *yy_start_stack = NULL; static void yy_push_state (int new_state ); static void yy_pop_state (void ); static int yy_top_state (void ); /* Amount of stuff to slurp up with each read. */#ifndef YY_READ_BUF_SIZE#define YY_READ_BUF_SIZE 8192#endif/* Copy whatever the last rule matched to the standard output. */#ifndef ECHO/* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */#define ECHO fwrite( swf5text, swf5leng, 1, swf5out )#endif/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, * is returned in "result". */#ifndef YY_INPUT#define YY_INPUT(buf,result,max_size) \ if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ size_t n; \ for ( n = 0; n < max_size && \ (c = getc( swf5in )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ if ( c == '\n' ) \ buf[n++] = (char) c; \ if ( c == EOF && ferror( swf5in ) ) \ YY_FATAL_ERROR( "input in flex scanner failed" ); \ result = n; \ } \ else \ { \ errno=0; \ while ( (result = fread(buf, 1, max_size, swf5in))==0 && ferror(swf5in)) \ { \ if( errno != EINTR) \ { \ YY_FATAL_ERROR( "input in flex scanner failed" ); \ break; \ } \ errno=0; \ clearerr(swf5in); \ } \ }\\#endif/* 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. */#ifndef yyterminate#define yyterminate() return YY_NULL#endif/* Number of entries by which start-condition stack grows. */#ifndef YY_START_STACK_INCR#define YY_START_STACK_INCR 25#endif/* Report a fatal error. */#ifndef YY_FATAL_ERROR#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )#endif/* end tables serialization structures and prototypes *//* Default declaration of generated scanner - a define so the user can * easily add parameters. */#ifndef YY_DECL#define YY_DECL_IS_OURS 1extern int swf5lex (void);#define YY_DECL int swf5lex (void)#endif /* !YY_DECL *//* Code executed at the beginning of each rule, after swf5text and swf5leng * have been set up. */#ifndef YY_USER_ACTION#define YY_USER_ACTION#endif/* Code executed at the end of each rule. */#ifndef YY_BREAK#define YY_BREAK break;#endif#define YY_RULE_SETUP \ YY_USER_ACTION/** The main scanner function which does all the work. */YY_DECL{ register yy_state_type yy_current_state; register char *yy_cp, *yy_bp; register int yy_act; #line 137 "./swf5compiler.flex"if (yy_first_time) { /* start in legacy state */ yy_push_state(STATE_LEGACY); yy_first_time = 0; /* suppress unused warning for static declared function */ yy_top_state();}#line 1430 "lex.swf5.c" if ( !(yy_init) ) { (yy_init) = 1;#ifdef YY_USER_INIT YY_USER_INIT;#endif if ( ! (yy_start) ) (yy_start) = 1; /* first start state */ if ( ! swf5in ) swf5in = stdin; if ( ! swf5out ) swf5out = stdout; if ( ! YY_CURRENT_BUFFER ) { swf5ensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = swf5_create_buffer(swf5in,YY_BUF_SIZE ); } swf5_load_buffer_state( ); } while ( 1 ) /* loops until end-of-file is reached */ { yy_cp = (yy_c_buf_p); /* Support of swf5text. */ *yy_cp = (yy_hold_char); /* yy_bp points to the position in yy_ch_buf of the start of
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -