未验证 提交 0318c8ac 编写于 作者: 羽飞's avatar 羽飞 提交者: GitHub

format lex file (#67)

format lex file
上级 84b9b420
此差异已折叠。
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#line 6 "lex.yy.h" #line 6 "lex.yy.h"
#define YY_INT_ALIGNED short int #define YY_INT_ALIGNED short int
/* A lexical scanner generated by flex */ /* A lexical scanner generated by flex */
...@@ -33,10 +33,10 @@ ...@@ -33,10 +33,10 @@
/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */ /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
* if you want the limit (max/min) macros for int types. * if you want the limit (max/min) macros for int types.
*/ */
#ifndef __STDC_LIMIT_MACROS #ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS 1 #define __STDC_LIMIT_MACROS 1
...@@ -54,38 +54,38 @@ typedef uint64_t flex_uint64_t; ...@@ -54,38 +54,38 @@ typedef uint64_t flex_uint64_t;
typedef signed char flex_int8_t; typedef signed char flex_int8_t;
typedef short int flex_int16_t; typedef short int flex_int16_t;
typedef int flex_int32_t; typedef int flex_int32_t;
typedef unsigned char flex_uint8_t; typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t; typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t; typedef unsigned int flex_uint32_t;
#endif /* ! C99 */ #endif /* ! C99 */
/* Limits of integral types. */ /* Limits of integral types. */
#ifndef INT8_MIN #ifndef INT8_MIN
#define INT8_MIN (-128) #define INT8_MIN (-128)
#endif #endif
#ifndef INT16_MIN #ifndef INT16_MIN
#define INT16_MIN (-32767 - 1) #define INT16_MIN (-32767-1)
#endif #endif
#ifndef INT32_MIN #ifndef INT32_MIN
#define INT32_MIN (-2147483647 - 1) #define INT32_MIN (-2147483647-1)
#endif #endif
#ifndef INT8_MAX #ifndef INT8_MAX
#define INT8_MAX (127) #define INT8_MAX (127)
#endif #endif
#ifndef INT16_MAX #ifndef INT16_MAX
#define INT16_MAX (32767) #define INT16_MAX (32767)
#endif #endif
#ifndef INT32_MAX #ifndef INT32_MAX
#define INT32_MAX (2147483647) #define INT32_MAX (2147483647)
#endif #endif
#ifndef UINT8_MAX #ifndef UINT8_MAX
#define UINT8_MAX (255U) #define UINT8_MAX (255U)
#endif #endif
#ifndef UINT16_MAX #ifndef UINT16_MAX
#define UINT16_MAX (65535U) #define UINT16_MAX (65535U)
#endif #endif
#ifndef UINT32_MAX #ifndef UINT32_MAX
#define UINT32_MAX (4294967295U) #define UINT32_MAX (4294967295U)
#endif #endif
#endif /* ! FLEXINT_H */ #endif /* ! FLEXINT_H */
...@@ -95,15 +95,15 @@ typedef unsigned int flex_uint32_t; ...@@ -95,15 +95,15 @@ typedef unsigned int flex_uint32_t;
/* The "const" storage-class-modifier is valid. */ /* The "const" storage-class-modifier is valid. */
#define YY_USE_CONST #define YY_USE_CONST
#else /* ! __cplusplus */ #else /* ! __cplusplus */
/* C99 requires __STDC__ to be defined as 1. */ /* C99 requires __STDC__ to be defined as 1. */
#if defined(__STDC__) #if defined (__STDC__)
#define YY_USE_CONST #define YY_USE_CONST
#endif /* defined (__STDC__) */ #endif /* defined (__STDC__) */
#endif /* ! __cplusplus */ #endif /* ! __cplusplus */
#ifdef YY_USE_CONST #ifdef YY_USE_CONST
#define yyconst const #define yyconst const
...@@ -114,7 +114,7 @@ typedef unsigned int flex_uint32_t; ...@@ -114,7 +114,7 @@ typedef unsigned int flex_uint32_t;
/* An opaque pointer. */ /* An opaque pointer. */
#ifndef YY_TYPEDEF_YY_SCANNER_T #ifndef YY_TYPEDEF_YY_SCANNER_T
#define YY_TYPEDEF_YY_SCANNER_T #define YY_TYPEDEF_YY_SCANNER_T
typedef void *yyscan_t; typedef void* yyscan_t;
#endif #endif
/* For convenience, these vars (plus the bison vars far below) /* For convenience, these vars (plus the bison vars far below)
...@@ -145,68 +145,70 @@ typedef size_t yy_size_t; ...@@ -145,68 +145,70 @@ typedef size_t yy_size_t;
#ifndef YY_STRUCT_YY_BUFFER_STATE #ifndef YY_STRUCT_YY_BUFFER_STATE
#define YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE
struct yy_buffer_state { struct yy_buffer_state
FILE *yy_input_file; {
FILE *yy_input_file;
char *yy_ch_buf; /* input buffer */
char *yy_buf_pos; /* current position in input buffer */ char *yy_ch_buf; /* input buffer */
char *yy_buf_pos; /* current position in input buffer */
/* Size of input buffer in bytes, not including room for EOB
* characters. /* Size of input buffer in bytes, not including room for EOB
*/ * characters.
yy_size_t yy_buf_size; */
yy_size_t yy_buf_size;
/* Number of characters read into yy_ch_buf, not including EOB
* characters. /* Number of characters read into yy_ch_buf, not including EOB
*/ * characters.
yy_size_t yy_n_chars; */
yy_size_t yy_n_chars;
/* Whether we "own" the buffer - i.e., we know we created it,
* and can realloc() it to grow it, and should free() it to /* Whether we "own" the buffer - i.e., we know we created it,
* delete it. * and can realloc() it to grow it, and should free() it to
*/ * delete it.
int yy_is_our_buffer; */
int yy_is_our_buffer;
/* Whether this is an "interactive" input source; if so, and
* if we're using stdio for input, then we want to use getc() /* Whether this is an "interactive" input source; if so, and
* instead of fread(), to make sure we stop fetching input after * if we're using stdio for input, then we want to use getc()
* each newline. * instead of fread(), to make sure we stop fetching input after
*/ * each newline.
int yy_is_interactive; */
int yy_is_interactive;
/* Whether we're considered to be at the beginning of a line.
* If so, '^' rules will be active on the next match, otherwise /* Whether we're considered to be at the beginning of a line.
* not. * If so, '^' rules will be active on the next match, otherwise
*/ * not.
int yy_at_bol; */
int yy_at_bol;
int yy_bs_lineno; /**< The line count. */
int yy_bs_column; /**< The column count. */ int yy_bs_lineno; /**< The line count. */
int yy_bs_column; /**< The column count. */
/* Whether to try to fill the input buffer when we reach the
* end of it. /* Whether to try to fill the input buffer when we reach the
*/ * end of it.
int yy_fill_buffer; */
int yy_fill_buffer;
int yy_buffer_status;
}; int yy_buffer_status;
};
#endif /* !YY_STRUCT_YY_BUFFER_STATE */ #endif /* !YY_STRUCT_YY_BUFFER_STATE */
void yyrestart(FILE *input_file, yyscan_t yyscanner); void yyrestart (FILE *input_file ,yyscan_t yyscanner );
void yy_switch_to_buffer(YY_BUFFER_STATE new_buffer, yyscan_t yyscanner); void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
YY_BUFFER_STATE yy_create_buffer(FILE *file, int size, yyscan_t yyscanner); YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner );
void yy_delete_buffer(YY_BUFFER_STATE b, yyscan_t yyscanner); void yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
void yy_flush_buffer(YY_BUFFER_STATE b, yyscan_t yyscanner); void yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
void yypush_buffer_state(YY_BUFFER_STATE new_buffer, yyscan_t yyscanner); void yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
void yypop_buffer_state(yyscan_t yyscanner); void yypop_buffer_state (yyscan_t yyscanner );
YY_BUFFER_STATE yy_scan_buffer(char *base, yy_size_t size, yyscan_t yyscanner); YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
YY_BUFFER_STATE yy_scan_string(yyconst char *yy_str, yyscan_t yyscanner); YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
YY_BUFFER_STATE yy_scan_bytes(yyconst char *bytes, yy_size_t len, yyscan_t yyscanner); YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len ,yyscan_t yyscanner );
void *yyalloc(yy_size_t, yyscan_t yyscanner); void *yyalloc (yy_size_t ,yyscan_t yyscanner );
void *yyrealloc(void *, yy_size_t, yyscan_t yyscanner); void *yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
void yyfree(void *, yyscan_t yyscanner); void yyfree (void * ,yyscan_t yyscanner );
/* Begin user sect3 */ /* Begin user sect3 */
...@@ -233,42 +235,42 @@ void yyfree(void *, yyscan_t yyscanner); ...@@ -233,42 +235,42 @@ void yyfree(void *, yyscan_t yyscanner);
#define YY_EXTRA_TYPE void * #define YY_EXTRA_TYPE void *
#endif #endif
int yylex_init(yyscan_t *scanner); int yylex_init (yyscan_t* scanner);
int yylex_init_extra(YY_EXTRA_TYPE user_defined, yyscan_t *scanner); int yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
/* Accessor methods to globals. /* Accessor methods to globals.
These are made visible to non-reentrant scanners for convenience. */ These are made visible to non-reentrant scanners for convenience. */
int yylex_destroy(yyscan_t yyscanner); int yylex_destroy (yyscan_t yyscanner );
int yyget_debug(yyscan_t yyscanner); int yyget_debug (yyscan_t yyscanner );
void yyset_debug(int debug_flag, yyscan_t yyscanner); void yyset_debug (int debug_flag ,yyscan_t yyscanner );
YY_EXTRA_TYPE yyget_extra(yyscan_t yyscanner); YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner );
void yyset_extra(YY_EXTRA_TYPE user_defined, yyscan_t yyscanner); void yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
FILE *yyget_in(yyscan_t yyscanner); FILE *yyget_in (yyscan_t yyscanner );
void yyset_in(FILE *in_str, yyscan_t yyscanner); void yyset_in (FILE * in_str ,yyscan_t yyscanner );
FILE *yyget_out(yyscan_t yyscanner); FILE *yyget_out (yyscan_t yyscanner );
void yyset_out(FILE *out_str, yyscan_t yyscanner); void yyset_out (FILE * out_str ,yyscan_t yyscanner );
yy_size_t yyget_leng(yyscan_t yyscanner); yy_size_t yyget_leng (yyscan_t yyscanner );
char *yyget_text(yyscan_t yyscanner); char *yyget_text (yyscan_t yyscanner );
int yyget_lineno(yyscan_t yyscanner); int yyget_lineno (yyscan_t yyscanner );
void yyset_lineno(int line_number, yyscan_t yyscanner); void yyset_lineno (int line_number ,yyscan_t yyscanner );
YYSTYPE *yyget_lval(yyscan_t yyscanner); YYSTYPE * yyget_lval (yyscan_t yyscanner );
void yyset_lval(YYSTYPE *yylval_param, yyscan_t yyscanner); void yyset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
/* Macros after this point can all be overridden by user definitions in /* Macros after this point can all be overridden by user definitions in
* section 1. * section 1.
...@@ -276,18 +278,18 @@ void yyset_lval(YYSTYPE *yylval_param, yyscan_t yyscanner); ...@@ -276,18 +278,18 @@ void yyset_lval(YYSTYPE *yylval_param, yyscan_t yyscanner);
#ifndef YY_SKIP_YYWRAP #ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus #ifdef __cplusplus
extern "C" int yywrap(yyscan_t yyscanner); extern "C" int yywrap (yyscan_t yyscanner );
#else #else
extern int yywrap(yyscan_t yyscanner); extern int yywrap (yyscan_t yyscanner );
#endif #endif
#endif #endif
#ifndef yytext_ptr #ifndef yytext_ptr
static void yy_flex_strncpy(char *, yyconst char *, int, yyscan_t yyscanner); static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
#endif #endif
#ifdef YY_NEED_STRLEN #ifdef YY_NEED_STRLEN
static int yy_flex_strlen(yyconst char *, yyscan_t yyscanner); static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
#endif #endif
#ifndef YY_NO_INPUT #ifndef YY_NO_INPUT
...@@ -310,9 +312,11 @@ static int yy_flex_strlen(yyconst char *, yyscan_t yyscanner); ...@@ -310,9 +312,11 @@ static int yy_flex_strlen(yyconst char *, yyscan_t yyscanner);
#ifndef YY_DECL #ifndef YY_DECL
#define YY_DECL_IS_OURS 1 #define YY_DECL_IS_OURS 1
extern int yylex(YYSTYPE *yylval_param, yyscan_t yyscanner); extern int yylex \
(YYSTYPE * yylval_param ,yyscan_t yyscanner);
#define YY_DECL int yylex(YYSTYPE *yylval_param, yyscan_t yyscanner) #define YY_DECL int yylex \
(YYSTYPE * yylval_param , yyscan_t yyscanner)
#endif /* !YY_DECL */ #endif /* !YY_DECL */
/* yy_get_previous_state - get the state just before the EOB char was reached */ /* yy_get_previous_state - get the state just before the EOB char was reached */
...@@ -329,7 +333,8 @@ extern int yylex(YYSTYPE *yylval_param, yyscan_t yyscanner); ...@@ -329,7 +333,8 @@ extern int yylex(YYSTYPE *yylval_param, yyscan_t yyscanner);
#undef YY_DECL #undef YY_DECL
#endif #endif
#line 86 "lex_sql.l" #line 88 "lex_sql.l"
#line 340 "lex.yy.h" #line 340 "lex.yy.h"
#undef yyIN_HEADER #undef yyIN_HEADER
......
...@@ -32,61 +32,61 @@ QUOTE [\'\"] ...@@ -32,61 +32,61 @@ QUOTE [\'\"]
%% %%
{WHITE_SAPCE} // ignore whitespace {WHITE_SAPCE} // ignore whitespace
\n ; \n ;
[\-]?{DIGIT}+ yylval->number=atoi(yytext); RETURN_TOKEN(NUMBER); [\-]?{DIGIT}+ yylval->number=atoi(yytext); RETURN_TOKEN(NUMBER);
[\-]?{DIGIT}+{DOT}{DIGIT}+ yylval->floats=(float)(atof(yytext)); RETURN_TOKEN(FLOAT); [\-]?{DIGIT}+{DOT}{DIGIT}+ yylval->floats=(float)(atof(yytext)); RETURN_TOKEN(FLOAT);
";" RETURN_TOKEN(SEMICOLON); ";" RETURN_TOKEN(SEMICOLON);
{DOT} RETURN_TOKEN(DOT); {DOT} RETURN_TOKEN(DOT);
"*" RETURN_TOKEN(STAR); "*" RETURN_TOKEN(STAR);
[Ee][Xx][Ii][Tt] RETURN_TOKEN(EXIT); [Ee][Xx][Ii][Tt] RETURN_TOKEN(EXIT);
[Hh][Ee][Ll][Pp] RETURN_TOKEN(HELP); [Hh][Ee][Ll][Pp] RETURN_TOKEN(HELP);
[Dd][Ee][Ss][Cc] RETURN_TOKEN(DESC); [Dd][Ee][Ss][Cc] RETURN_TOKEN(DESC);
[Cc][Rr][Ee][Aa][Tt][Ee] RETURN_TOKEN(CREATE); [Cc][Rr][Ee][Aa][Tt][Ee] RETURN_TOKEN(CREATE);
[Dd][Rr][Oo][Pp] RETURN_TOKEN(DROP); [Dd][Rr][Oo][Pp] RETURN_TOKEN(DROP);
[Tt][Aa][Bb][Ll][Ee] RETURN_TOKEN(TABLE); [Tt][Aa][Bb][Ll][Ee] RETURN_TOKEN(TABLE);
[Tt][Aa][Bb][Ll][Ee][Ss] RETURN_TOKEN(TABLES); [Tt][Aa][Bb][Ll][Ee][Ss] RETURN_TOKEN(TABLES);
[Ii][Nn][Dd][Ee][Xx] RETURN_TOKEN(INDEX); [Ii][Nn][Dd][Ee][Xx] RETURN_TOKEN(INDEX);
[Oo][Nn] RETURN_TOKEN(ON); [Oo][Nn] RETURN_TOKEN(ON);
[Ss][Hh][Oo][Ww] RETURN_TOKEN(SHOW); [Ss][Hh][Oo][Ww] RETURN_TOKEN(SHOW);
[Ss][Yy][Nn][Cc] RETURN_TOKEN(SYNC); [Ss][Yy][Nn][Cc] RETURN_TOKEN(SYNC);
[Ss][Ee][Ll][Ee][Cc][Tt] RETURN_TOKEN(SELECT); [Ss][Ee][Ll][Ee][Cc][Tt] RETURN_TOKEN(SELECT);
[Ff][Rr][Oo][Mm] RETURN_TOKEN(FROM); [Ff][Rr][Oo][Mm] RETURN_TOKEN(FROM);
[Ww][Hh][Ee][Rr][Ee] RETURN_TOKEN(WHERE); [Ww][Hh][Ee][Rr][Ee] RETURN_TOKEN(WHERE);
[Aa][Nn][Dd] RETURN_TOKEN(AND); [Aa][Nn][Dd] RETURN_TOKEN(AND);
[Ii][Nn][Ss][Ee][rR][tT] RETURN_TOKEN(INSERT); [Ii][Nn][Ss][Ee][rR][tT] RETURN_TOKEN(INSERT);
[Ii][Nn][Tt][Oo] RETURN_TOKEN(INTO); [Ii][Nn][Tt][Oo] RETURN_TOKEN(INTO);
[Vv][Aa][Ll][Uu][Ee][Ss] RETURN_TOKEN(VALUES); [Vv][Aa][Ll][Uu][Ee][Ss] RETURN_TOKEN(VALUES);
[Dd][Ee][Ll][Ee][Tt][Ee] RETURN_TOKEN(DELETE); [Dd][Ee][Ll][Ee][Tt][Ee] RETURN_TOKEN(DELETE);
[Uu][Pp][Dd][Aa][Tt][Ee] RETURN_TOKEN(UPDATE); [Uu][Pp][Dd][Aa][Tt][Ee] RETURN_TOKEN(UPDATE);
[Ss][Ee][Tt] RETURN_TOKEN(SET); [Ss][Ee][Tt] RETURN_TOKEN(SET);
[Bb][Ee][Gg][Ii][Nn] RETURN_TOKEN(TRX_BEGIN); [Bb][Ee][Gg][Ii][Nn] RETURN_TOKEN(TRX_BEGIN);
[Cc][Oo][Mm][Mm][Ii][Tt] RETURN_TOKEN(TRX_COMMIT); [Cc][Oo][Mm][Mm][Ii][Tt] RETURN_TOKEN(TRX_COMMIT);
[Rr][Oo][Ll][Ll][Bb][Aa][Cc][Kk] RETURN_TOKEN(TRX_ROLLBACK); [Rr][Oo][Ll][Ll][Bb][Aa][Cc][Kk] RETURN_TOKEN(TRX_ROLLBACK);
[Ii][Nn][Tt] RETURN_TOKEN(INT_T); [Ii][Nn][Tt] RETURN_TOKEN(INT_T);
[Cc][Hh][Aa][Rr] RETURN_TOKEN(STRING_T); [Cc][Hh][Aa][Rr] RETURN_TOKEN(STRING_T);
[Ff][Ll][Oo][Aa][Tt] RETURN_TOKEN(FLOAT_T); [Ff][Ll][Oo][Aa][Tt] RETURN_TOKEN(FLOAT_T);
[Ll][Oo][Aa][Dd] RETURN_TOKEN(LOAD); [Ll][Oo][Aa][Dd] RETURN_TOKEN(LOAD);
[Dd][Aa][Tt][Aa] RETURN_TOKEN(DATA); [Dd][Aa][Tt][Aa] RETURN_TOKEN(DATA);
[Ii][Nn][Ff][Ii][Ll][Ee] RETURN_TOKEN(INFILE); [Ii][Nn][Ff][Ii][Ll][Ee] RETURN_TOKEN(INFILE);
{ID} yylval->string=strdup(yytext); RETURN_TOKEN(ID); {ID} yylval->string=strdup(yytext); RETURN_TOKEN(ID);
"(" RETURN_TOKEN(LBRACE); "(" RETURN_TOKEN(LBRACE);
")" RETURN_TOKEN(RBRACE); ")" RETURN_TOKEN(RBRACE);
"," RETURN_TOKEN(COMMA); "," RETURN_TOKEN(COMMA);
"=" RETURN_TOKEN(EQ); "=" RETURN_TOKEN(EQ);
"<=" RETURN_TOKEN(LE); "<=" RETURN_TOKEN(LE);
"<>" RETURN_TOKEN(NE); "<>" RETURN_TOKEN(NE);
"<" RETURN_TOKEN(LT); "<" RETURN_TOKEN(LT);
">=" RETURN_TOKEN(GE); ">=" RETURN_TOKEN(GE);
">" RETURN_TOKEN(GT); ">" RETURN_TOKEN(GT);
{QUOTE}[\40\42\47A-Za-z0-9_/\.\-]*{QUOTE} yylval->string=strdup(yytext); RETURN_TOKEN(SSS); {QUOTE}[\40\42\47A-Za-z0-9_/\.\-]*{QUOTE} yylval->string=strdup(yytext); RETURN_TOKEN(SSS);
. printf("Unknown character [%c]\n",yytext[0]); return yytext[0]; . printf("Unknown character [%c]\n",yytext[0]); return yytext[0];
%% %%
void scan_string(const char *str, yyscan_t scanner) { void scan_string(const char *str, yyscan_t scanner) {
yy_switch_to_buffer(yy_scan_string(str, scanner), scanner); yy_switch_to_buffer(yy_scan_string(str, scanner), scanner);
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册