Add enum types for formerly 'simple' operands (#48)
* Add enum types for formerly 'simple' operands * Use non-semantic names * Formatting * Add generated files
This commit is contained in:
parent
8913f9213d
commit
6a05b8e94b
|
@ -32,6 +32,12 @@ lib-test/
|
|||
*.out
|
||||
*.app
|
||||
|
||||
# IDE
|
||||
.idea/
|
||||
|
||||
# CMAKE
|
||||
cmake-build-debug/
|
||||
|
||||
*.cpp.orig
|
||||
*.h.orig
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -48,9 +48,9 @@
|
|||
extern int hsql_debug;
|
||||
#endif
|
||||
/* "%code requires" blocks. */
|
||||
#line 34 "bison_parser.y" /* yacc.c:1909 */
|
||||
#line 34 "bison_parser.y" /* yacc.c:1915 */
|
||||
|
||||
// %code requires block
|
||||
// %code requires block
|
||||
|
||||
#include "../sql/statements.h"
|
||||
#include "../SQLParserResult.h"
|
||||
|
@ -71,7 +71,7 @@ extern int hsql_debug;
|
|||
} \
|
||||
}
|
||||
|
||||
#line 75 "bison_parser.h" /* yacc.c:1909 */
|
||||
#line 75 "bison_parser.h" /* yacc.c:1915 */
|
||||
|
||||
/* Token type. */
|
||||
#ifndef HSQL_TOKENTYPE
|
||||
|
@ -214,7 +214,7 @@ extern int hsql_debug;
|
|||
|
||||
union HSQL_STYPE
|
||||
{
|
||||
#line 92 "bison_parser.y" /* yacc.c:1909 */
|
||||
#line 92 "bison_parser.y" /* yacc.c:1915 */
|
||||
|
||||
double fval;
|
||||
int64_t ival;
|
||||
|
@ -251,7 +251,7 @@ union HSQL_STYPE
|
|||
std::vector<hsql::Expr*>* expr_vec;
|
||||
std::vector<hsql::OrderDescription*>* order_vec;
|
||||
|
||||
#line 255 "bison_parser.h" /* yacc.c:1909 */
|
||||
#line 255 "bison_parser.h" /* yacc.c:1915 */
|
||||
};
|
||||
|
||||
typedef union HSQL_STYPE HSQL_STYPE;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* bison_parser.y
|
||||
* defines bison_parser.h
|
||||
* outputs bison_parser.c
|
||||
*
|
||||
*
|
||||
* Grammar File Spec: http://dinosaur.compilertools.net/bison/bison_6.html
|
||||
*
|
||||
*/
|
||||
|
@ -32,7 +32,7 @@ int yyerror(YYLTYPE* llocp, SQLParserResult* result, yyscan_t scanner, const cha
|
|||
|
||||
// Specify code that is included in the generated .h and .c files
|
||||
%code requires {
|
||||
// %code requires block
|
||||
// %code requires block
|
||||
|
||||
#include "../sql/statements.h"
|
||||
#include "../SQLParserResult.h"
|
||||
|
@ -639,7 +639,7 @@ opt_limit:
|
|||
;
|
||||
|
||||
/******************************
|
||||
* Expressions
|
||||
* Expressions
|
||||
******************************/
|
||||
expr_list:
|
||||
expr_alias { $$ = new std::vector<Expr*>(); $$->push_back($1); }
|
||||
|
@ -683,18 +683,18 @@ scalar_expr:
|
|||
;
|
||||
|
||||
unary_expr:
|
||||
'-' operand { $$ = Expr::makeOpUnary(kOpMinus, $2); }
|
||||
'-' operand { $$ = Expr::makeOpUnary(kOpUnaryMinus, $2); }
|
||||
| NOT operand { $$ = Expr::makeOpUnary(kOpNot, $2); }
|
||||
;
|
||||
|
||||
binary_expr:
|
||||
comp_expr
|
||||
| operand '-' operand { $$ = Expr::makeOpBinary($1, '-', $3); }
|
||||
| operand '+' operand { $$ = Expr::makeOpBinary($1, '+', $3); }
|
||||
| operand '/' operand { $$ = Expr::makeOpBinary($1, '/', $3); }
|
||||
| operand '*' operand { $$ = Expr::makeOpBinary($1, '*', $3); }
|
||||
| operand '%' operand { $$ = Expr::makeOpBinary($1, '%', $3); }
|
||||
| operand '^' operand { $$ = Expr::makeOpBinary($1, '^', $3); }
|
||||
| operand '-' operand { $$ = Expr::makeOpBinary($1, kOpMinus, $3); }
|
||||
| operand '+' operand { $$ = Expr::makeOpBinary($1, kOpPlus, $3); }
|
||||
| operand '/' operand { $$ = Expr::makeOpBinary($1, kOpSlash, $3); }
|
||||
| operand '*' operand { $$ = Expr::makeOpBinary($1, kOpAsterisk, $3); }
|
||||
| operand '%' operand { $$ = Expr::makeOpBinary($1, kOpPercentage, $3); }
|
||||
| operand '^' operand { $$ = Expr::makeOpBinary($1, kOpCaret, $3); }
|
||||
| operand LIKE operand { $$ = Expr::makeOpBinary($1, kOpLike, $3); }
|
||||
| operand NOT LIKE operand { $$ = Expr::makeOpBinary($1, kOpNotLike, $4); }
|
||||
;
|
||||
|
@ -722,10 +722,10 @@ exists_expr:
|
|||
;
|
||||
|
||||
comp_expr:
|
||||
operand '=' operand { $$ = Expr::makeOpBinary($1, '=', $3); }
|
||||
operand '=' operand { $$ = Expr::makeOpBinary($1, kOpEquals, $3); }
|
||||
| operand NOTEQUALS operand { $$ = Expr::makeOpBinary($1, kOpNotEquals, $3); }
|
||||
| operand '<' operand { $$ = Expr::makeOpBinary($1, '<', $3); }
|
||||
| operand '>' operand { $$ = Expr::makeOpBinary($1, '>', $3); }
|
||||
| operand '<' operand { $$ = Expr::makeOpBinary($1, kOpLess, $3); }
|
||||
| operand '>' operand { $$ = Expr::makeOpBinary($1, kOpGreater, $3); }
|
||||
| operand LESSEQ operand { $$ = Expr::makeOpBinary($1, kOpLessEq, $3); }
|
||||
| operand GREATEREQ operand { $$ = Expr::makeOpBinary($1, kOpGreaterEq, $3); }
|
||||
;
|
||||
|
@ -777,7 +777,7 @@ param_expr:
|
|||
|
||||
|
||||
/******************************
|
||||
* Table
|
||||
* Table
|
||||
******************************/
|
||||
table_ref:
|
||||
table_ref_atomic
|
||||
|
@ -832,7 +832,7 @@ table_name:
|
|||
;
|
||||
|
||||
|
||||
alias:
|
||||
alias:
|
||||
AS IDENTIFIER { $$ = $2; }
|
||||
| IDENTIFIER
|
||||
;
|
||||
|
@ -848,7 +848,7 @@ opt_alias:
|
|||
|
||||
join_clause:
|
||||
table_ref_atomic opt_join_type JOIN table_ref_atomic ON join_condition
|
||||
{
|
||||
{
|
||||
$$ = new TableRef(kTableJoin);
|
||||
$$->join = new JoinDefinition();
|
||||
$$->join->type = (JoinType) $2;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2,9 +2,9 @@
|
|||
#define hsql_HEADER_H 1
|
||||
#define hsql_IN_HEADER 1
|
||||
|
||||
#line 6 "flex_lexer.h"
|
||||
#line 5 "flex_lexer.h"
|
||||
|
||||
#line 8 "flex_lexer.h"
|
||||
#line 7 "flex_lexer.h"
|
||||
|
||||
#define YY_INT_ALIGNED short int
|
||||
|
||||
|
@ -13,11 +13,245 @@
|
|||
#define FLEX_SCANNER
|
||||
#define YY_FLEX_MAJOR_VERSION 2
|
||||
#define YY_FLEX_MINOR_VERSION 6
|
||||
#define YY_FLEX_SUBMINOR_VERSION 1
|
||||
#define YY_FLEX_SUBMINOR_VERSION 4
|
||||
#if YY_FLEX_SUBMINOR_VERSION > 0
|
||||
#define FLEX_BETA
|
||||
#endif
|
||||
|
||||
#ifdef yy_create_buffer
|
||||
#define hsql__create_buffer_ALREADY_DEFINED
|
||||
#else
|
||||
#define yy_create_buffer hsql__create_buffer
|
||||
#endif
|
||||
|
||||
#ifdef yy_delete_buffer
|
||||
#define hsql__delete_buffer_ALREADY_DEFINED
|
||||
#else
|
||||
#define yy_delete_buffer hsql__delete_buffer
|
||||
#endif
|
||||
|
||||
#ifdef yy_scan_buffer
|
||||
#define hsql__scan_buffer_ALREADY_DEFINED
|
||||
#else
|
||||
#define yy_scan_buffer hsql__scan_buffer
|
||||
#endif
|
||||
|
||||
#ifdef yy_scan_string
|
||||
#define hsql__scan_string_ALREADY_DEFINED
|
||||
#else
|
||||
#define yy_scan_string hsql__scan_string
|
||||
#endif
|
||||
|
||||
#ifdef yy_scan_bytes
|
||||
#define hsql__scan_bytes_ALREADY_DEFINED
|
||||
#else
|
||||
#define yy_scan_bytes hsql__scan_bytes
|
||||
#endif
|
||||
|
||||
#ifdef yy_init_buffer
|
||||
#define hsql__init_buffer_ALREADY_DEFINED
|
||||
#else
|
||||
#define yy_init_buffer hsql__init_buffer
|
||||
#endif
|
||||
|
||||
#ifdef yy_flush_buffer
|
||||
#define hsql__flush_buffer_ALREADY_DEFINED
|
||||
#else
|
||||
#define yy_flush_buffer hsql__flush_buffer
|
||||
#endif
|
||||
|
||||
#ifdef yy_load_buffer_state
|
||||
#define hsql__load_buffer_state_ALREADY_DEFINED
|
||||
#else
|
||||
#define yy_load_buffer_state hsql__load_buffer_state
|
||||
#endif
|
||||
|
||||
#ifdef yy_switch_to_buffer
|
||||
#define hsql__switch_to_buffer_ALREADY_DEFINED
|
||||
#else
|
||||
#define yy_switch_to_buffer hsql__switch_to_buffer
|
||||
#endif
|
||||
|
||||
#ifdef yypush_buffer_state
|
||||
#define hsql_push_buffer_state_ALREADY_DEFINED
|
||||
#else
|
||||
#define yypush_buffer_state hsql_push_buffer_state
|
||||
#endif
|
||||
|
||||
#ifdef yypop_buffer_state
|
||||
#define hsql_pop_buffer_state_ALREADY_DEFINED
|
||||
#else
|
||||
#define yypop_buffer_state hsql_pop_buffer_state
|
||||
#endif
|
||||
|
||||
#ifdef yyensure_buffer_stack
|
||||
#define hsql_ensure_buffer_stack_ALREADY_DEFINED
|
||||
#else
|
||||
#define yyensure_buffer_stack hsql_ensure_buffer_stack
|
||||
#endif
|
||||
|
||||
#ifdef yylex
|
||||
#define hsql_lex_ALREADY_DEFINED
|
||||
#else
|
||||
#define yylex hsql_lex
|
||||
#endif
|
||||
|
||||
#ifdef yyrestart
|
||||
#define hsql_restart_ALREADY_DEFINED
|
||||
#else
|
||||
#define yyrestart hsql_restart
|
||||
#endif
|
||||
|
||||
#ifdef yylex_init
|
||||
#define hsql_lex_init_ALREADY_DEFINED
|
||||
#else
|
||||
#define yylex_init hsql_lex_init
|
||||
#endif
|
||||
|
||||
#ifdef yylex_init_extra
|
||||
#define hsql_lex_init_extra_ALREADY_DEFINED
|
||||
#else
|
||||
#define yylex_init_extra hsql_lex_init_extra
|
||||
#endif
|
||||
|
||||
#ifdef yylex_destroy
|
||||
#define hsql_lex_destroy_ALREADY_DEFINED
|
||||
#else
|
||||
#define yylex_destroy hsql_lex_destroy
|
||||
#endif
|
||||
|
||||
#ifdef yyget_debug
|
||||
#define hsql_get_debug_ALREADY_DEFINED
|
||||
#else
|
||||
#define yyget_debug hsql_get_debug
|
||||
#endif
|
||||
|
||||
#ifdef yyset_debug
|
||||
#define hsql_set_debug_ALREADY_DEFINED
|
||||
#else
|
||||
#define yyset_debug hsql_set_debug
|
||||
#endif
|
||||
|
||||
#ifdef yyget_extra
|
||||
#define hsql_get_extra_ALREADY_DEFINED
|
||||
#else
|
||||
#define yyget_extra hsql_get_extra
|
||||
#endif
|
||||
|
||||
#ifdef yyset_extra
|
||||
#define hsql_set_extra_ALREADY_DEFINED
|
||||
#else
|
||||
#define yyset_extra hsql_set_extra
|
||||
#endif
|
||||
|
||||
#ifdef yyget_in
|
||||
#define hsql_get_in_ALREADY_DEFINED
|
||||
#else
|
||||
#define yyget_in hsql_get_in
|
||||
#endif
|
||||
|
||||
#ifdef yyset_in
|
||||
#define hsql_set_in_ALREADY_DEFINED
|
||||
#else
|
||||
#define yyset_in hsql_set_in
|
||||
#endif
|
||||
|
||||
#ifdef yyget_out
|
||||
#define hsql_get_out_ALREADY_DEFINED
|
||||
#else
|
||||
#define yyget_out hsql_get_out
|
||||
#endif
|
||||
|
||||
#ifdef yyset_out
|
||||
#define hsql_set_out_ALREADY_DEFINED
|
||||
#else
|
||||
#define yyset_out hsql_set_out
|
||||
#endif
|
||||
|
||||
#ifdef yyget_leng
|
||||
#define hsql_get_leng_ALREADY_DEFINED
|
||||
#else
|
||||
#define yyget_leng hsql_get_leng
|
||||
#endif
|
||||
|
||||
#ifdef yyget_text
|
||||
#define hsql_get_text_ALREADY_DEFINED
|
||||
#else
|
||||
#define yyget_text hsql_get_text
|
||||
#endif
|
||||
|
||||
#ifdef yyget_lineno
|
||||
#define hsql_get_lineno_ALREADY_DEFINED
|
||||
#else
|
||||
#define yyget_lineno hsql_get_lineno
|
||||
#endif
|
||||
|
||||
#ifdef yyset_lineno
|
||||
#define hsql_set_lineno_ALREADY_DEFINED
|
||||
#else
|
||||
#define yyset_lineno hsql_set_lineno
|
||||
#endif
|
||||
|
||||
#ifdef yyget_column
|
||||
#define hsql_get_column_ALREADY_DEFINED
|
||||
#else
|
||||
#define yyget_column hsql_get_column
|
||||
#endif
|
||||
|
||||
#ifdef yyset_column
|
||||
#define hsql_set_column_ALREADY_DEFINED
|
||||
#else
|
||||
#define yyset_column hsql_set_column
|
||||
#endif
|
||||
|
||||
#ifdef yywrap
|
||||
#define hsql_wrap_ALREADY_DEFINED
|
||||
#else
|
||||
#define yywrap hsql_wrap
|
||||
#endif
|
||||
|
||||
#ifdef yyget_lval
|
||||
#define hsql_get_lval_ALREADY_DEFINED
|
||||
#else
|
||||
#define yyget_lval hsql_get_lval
|
||||
#endif
|
||||
|
||||
#ifdef yyset_lval
|
||||
#define hsql_set_lval_ALREADY_DEFINED
|
||||
#else
|
||||
#define yyset_lval hsql_set_lval
|
||||
#endif
|
||||
|
||||
#ifdef yyget_lloc
|
||||
#define hsql_get_lloc_ALREADY_DEFINED
|
||||
#else
|
||||
#define yyget_lloc hsql_get_lloc
|
||||
#endif
|
||||
|
||||
#ifdef yyset_lloc
|
||||
#define hsql_set_lloc_ALREADY_DEFINED
|
||||
#else
|
||||
#define yyset_lloc hsql_set_lloc
|
||||
#endif
|
||||
|
||||
#ifdef yyalloc
|
||||
#define hsql_alloc_ALREADY_DEFINED
|
||||
#else
|
||||
#define yyalloc hsql_alloc
|
||||
#endif
|
||||
|
||||
#ifdef yyrealloc
|
||||
#define hsql_realloc_ALREADY_DEFINED
|
||||
#else
|
||||
#define yyrealloc hsql_realloc
|
||||
#endif
|
||||
|
||||
#ifdef yyfree
|
||||
#define hsql_free_ALREADY_DEFINED
|
||||
#else
|
||||
#define yyfree hsql_free
|
||||
#endif
|
||||
|
||||
/* First, we deal with platform-specific or compiler-specific issues. */
|
||||
|
||||
/* begin standard C headers. */
|
||||
|
@ -88,10 +322,16 @@ typedef unsigned int flex_uint32_t;
|
|||
#define UINT32_MAX (4294967295U)
|
||||
#endif
|
||||
|
||||
#ifndef SIZE_MAX
|
||||
#define SIZE_MAX (~(size_t)0)
|
||||
#endif
|
||||
|
||||
#endif /* ! C99 */
|
||||
|
||||
#endif /* ! FLEXINT_H */
|
||||
|
||||
/* begin standard C++ headers. */
|
||||
|
||||
/* TODO: this is always defined, so inline it */
|
||||
#define yyconst const
|
||||
|
||||
|
@ -192,21 +432,21 @@ struct yy_buffer_state
|
|||
};
|
||||
#endif /* !YY_STRUCT_YY_BUFFER_STATE */
|
||||
|
||||
void hsql_restart (FILE *input_file ,yyscan_t yyscanner );
|
||||
void hsql__switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
|
||||
YY_BUFFER_STATE hsql__create_buffer (FILE *file,int size ,yyscan_t yyscanner );
|
||||
void hsql__delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
|
||||
void hsql__flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
|
||||
void hsql_push_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
|
||||
void hsql_pop_buffer_state (yyscan_t yyscanner );
|
||||
void yyrestart ( FILE *input_file , 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 );
|
||||
void yy_delete_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 yypop_buffer_state ( yyscan_t yyscanner );
|
||||
|
||||
YY_BUFFER_STATE hsql__scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
|
||||
YY_BUFFER_STATE hsql__scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
|
||||
YY_BUFFER_STATE hsql__scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
|
||||
YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner );
|
||||
YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner );
|
||||
YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner );
|
||||
|
||||
void *hsql_alloc (yy_size_t ,yyscan_t yyscanner );
|
||||
void *hsql_realloc (void *,yy_size_t ,yyscan_t yyscanner );
|
||||
void hsql_free (void * ,yyscan_t yyscanner );
|
||||
void *yyalloc ( yy_size_t , yyscan_t yyscanner );
|
||||
void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner );
|
||||
void yyfree ( void * , yyscan_t yyscanner );
|
||||
|
||||
/* Begin user sect3 */
|
||||
|
||||
|
@ -233,50 +473,50 @@ void hsql_free (void * ,yyscan_t yyscanner );
|
|||
#define YY_EXTRA_TYPE void *
|
||||
#endif
|
||||
|
||||
int hsql_lex_init (yyscan_t* scanner);
|
||||
int yylex_init (yyscan_t* scanner);
|
||||
|
||||
int hsql_lex_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.
|
||||
These are made visible to non-reentrant scanners for convenience. */
|
||||
|
||||
int hsql_lex_destroy (yyscan_t yyscanner );
|
||||
int yylex_destroy ( yyscan_t yyscanner );
|
||||
|
||||
int hsql_get_debug (yyscan_t yyscanner );
|
||||
int yyget_debug ( yyscan_t yyscanner );
|
||||
|
||||
void hsql_set_debug (int debug_flag ,yyscan_t yyscanner );
|
||||
void yyset_debug ( int debug_flag , yyscan_t yyscanner );
|
||||
|
||||
YY_EXTRA_TYPE hsql_get_extra (yyscan_t yyscanner );
|
||||
YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner );
|
||||
|
||||
void hsql_set_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
|
||||
void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner );
|
||||
|
||||
FILE *hsql_get_in (yyscan_t yyscanner );
|
||||
FILE *yyget_in ( yyscan_t yyscanner );
|
||||
|
||||
void hsql_set_in (FILE * _in_str ,yyscan_t yyscanner );
|
||||
void yyset_in ( FILE * _in_str , yyscan_t yyscanner );
|
||||
|
||||
FILE *hsql_get_out (yyscan_t yyscanner );
|
||||
FILE *yyget_out ( yyscan_t yyscanner );
|
||||
|
||||
void hsql_set_out (FILE * _out_str ,yyscan_t yyscanner );
|
||||
void yyset_out ( FILE * _out_str , yyscan_t yyscanner );
|
||||
|
||||
int hsql_get_leng (yyscan_t yyscanner );
|
||||
int yyget_leng ( yyscan_t yyscanner );
|
||||
|
||||
char *hsql_get_text (yyscan_t yyscanner );
|
||||
char *yyget_text ( yyscan_t yyscanner );
|
||||
|
||||
int hsql_get_lineno (yyscan_t yyscanner );
|
||||
int yyget_lineno ( yyscan_t yyscanner );
|
||||
|
||||
void hsql_set_lineno (int _line_number ,yyscan_t yyscanner );
|
||||
void yyset_lineno ( int _line_number , yyscan_t yyscanner );
|
||||
|
||||
int hsql_get_column (yyscan_t yyscanner );
|
||||
int yyget_column ( yyscan_t yyscanner );
|
||||
|
||||
void hsql_set_column (int _column_no ,yyscan_t yyscanner );
|
||||
void yyset_column ( int _column_no , yyscan_t yyscanner );
|
||||
|
||||
YYSTYPE * hsql_get_lval (yyscan_t yyscanner );
|
||||
YYSTYPE * yyget_lval ( yyscan_t yyscanner );
|
||||
|
||||
void hsql_set_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
|
||||
void yyset_lval ( YYSTYPE * yylval_param , yyscan_t yyscanner );
|
||||
|
||||
YYLTYPE *hsql_get_lloc (yyscan_t yyscanner );
|
||||
YYLTYPE *yyget_lloc ( yyscan_t yyscanner );
|
||||
|
||||
void hsql_set_lloc (YYLTYPE * yylloc_param ,yyscan_t yyscanner );
|
||||
void yyset_lloc ( YYLTYPE * yylloc_param , yyscan_t yyscanner );
|
||||
|
||||
/* Macros after this point can all be overridden by user definitions in
|
||||
* section 1.
|
||||
|
@ -284,18 +524,18 @@ void hsql_set_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
|
|||
|
||||
#ifndef YY_SKIP_YYWRAP
|
||||
#ifdef __cplusplus
|
||||
extern "C" int hsql_wrap (yyscan_t yyscanner );
|
||||
extern "C" int yywrap ( yyscan_t yyscanner );
|
||||
#else
|
||||
extern int hsql_wrap (yyscan_t yyscanner );
|
||||
extern int yywrap ( yyscan_t yyscanner );
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef yytext_ptr
|
||||
static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
|
||||
static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner);
|
||||
#endif
|
||||
|
||||
#ifdef YY_NEED_STRLEN
|
||||
static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
|
||||
static int yy_flex_strlen ( const char * , yyscan_t yyscanner);
|
||||
#endif
|
||||
|
||||
#ifndef YY_NO_INPUT
|
||||
|
@ -323,10 +563,10 @@ static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
|
|||
#ifndef YY_DECL
|
||||
#define YY_DECL_IS_OURS 1
|
||||
|
||||
extern int hsql_lex \
|
||||
(YYSTYPE * yylval_param,YYLTYPE * yylloc_param ,yyscan_t yyscanner);
|
||||
extern int yylex \
|
||||
(YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner);
|
||||
|
||||
#define YY_DECL int hsql_lex \
|
||||
#define YY_DECL int yylex \
|
||||
(YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner)
|
||||
#endif /* !YY_DECL */
|
||||
|
||||
|
@ -344,9 +584,154 @@ extern int hsql_lex \
|
|||
#undef YY_DECL
|
||||
#endif
|
||||
|
||||
#ifndef hsql__create_buffer_ALREADY_DEFINED
|
||||
#undef yy_create_buffer
|
||||
#endif
|
||||
#ifndef hsql__delete_buffer_ALREADY_DEFINED
|
||||
#undef yy_delete_buffer
|
||||
#endif
|
||||
#ifndef hsql__scan_buffer_ALREADY_DEFINED
|
||||
#undef yy_scan_buffer
|
||||
#endif
|
||||
#ifndef hsql__scan_string_ALREADY_DEFINED
|
||||
#undef yy_scan_string
|
||||
#endif
|
||||
#ifndef hsql__scan_bytes_ALREADY_DEFINED
|
||||
#undef yy_scan_bytes
|
||||
#endif
|
||||
#ifndef hsql__init_buffer_ALREADY_DEFINED
|
||||
#undef yy_init_buffer
|
||||
#endif
|
||||
#ifndef hsql__flush_buffer_ALREADY_DEFINED
|
||||
#undef yy_flush_buffer
|
||||
#endif
|
||||
#ifndef hsql__load_buffer_state_ALREADY_DEFINED
|
||||
#undef yy_load_buffer_state
|
||||
#endif
|
||||
#ifndef hsql__switch_to_buffer_ALREADY_DEFINED
|
||||
#undef yy_switch_to_buffer
|
||||
#endif
|
||||
#ifndef hsql_push_buffer_state_ALREADY_DEFINED
|
||||
#undef yypush_buffer_state
|
||||
#endif
|
||||
#ifndef hsql_pop_buffer_state_ALREADY_DEFINED
|
||||
#undef yypop_buffer_state
|
||||
#endif
|
||||
#ifndef hsql_ensure_buffer_stack_ALREADY_DEFINED
|
||||
#undef yyensure_buffer_stack
|
||||
#endif
|
||||
#ifndef hsql_lex_ALREADY_DEFINED
|
||||
#undef yylex
|
||||
#endif
|
||||
#ifndef hsql_restart_ALREADY_DEFINED
|
||||
#undef yyrestart
|
||||
#endif
|
||||
#ifndef hsql_lex_init_ALREADY_DEFINED
|
||||
#undef yylex_init
|
||||
#endif
|
||||
#ifndef hsql_lex_init_extra_ALREADY_DEFINED
|
||||
#undef yylex_init_extra
|
||||
#endif
|
||||
#ifndef hsql_lex_destroy_ALREADY_DEFINED
|
||||
#undef yylex_destroy
|
||||
#endif
|
||||
#ifndef hsql_get_debug_ALREADY_DEFINED
|
||||
#undef yyget_debug
|
||||
#endif
|
||||
#ifndef hsql_set_debug_ALREADY_DEFINED
|
||||
#undef yyset_debug
|
||||
#endif
|
||||
#ifndef hsql_get_extra_ALREADY_DEFINED
|
||||
#undef yyget_extra
|
||||
#endif
|
||||
#ifndef hsql_set_extra_ALREADY_DEFINED
|
||||
#undef yyset_extra
|
||||
#endif
|
||||
#ifndef hsql_get_in_ALREADY_DEFINED
|
||||
#undef yyget_in
|
||||
#endif
|
||||
#ifndef hsql_set_in_ALREADY_DEFINED
|
||||
#undef yyset_in
|
||||
#endif
|
||||
#ifndef hsql_get_out_ALREADY_DEFINED
|
||||
#undef yyget_out
|
||||
#endif
|
||||
#ifndef hsql_set_out_ALREADY_DEFINED
|
||||
#undef yyset_out
|
||||
#endif
|
||||
#ifndef hsql_get_leng_ALREADY_DEFINED
|
||||
#undef yyget_leng
|
||||
#endif
|
||||
#ifndef hsql_get_text_ALREADY_DEFINED
|
||||
#undef yyget_text
|
||||
#endif
|
||||
#ifndef hsql_get_lineno_ALREADY_DEFINED
|
||||
#undef yyget_lineno
|
||||
#endif
|
||||
#ifndef hsql_set_lineno_ALREADY_DEFINED
|
||||
#undef yyset_lineno
|
||||
#endif
|
||||
#ifndef hsql_get_column_ALREADY_DEFINED
|
||||
#undef yyget_column
|
||||
#endif
|
||||
#ifndef hsql_set_column_ALREADY_DEFINED
|
||||
#undef yyset_column
|
||||
#endif
|
||||
#ifndef hsql_wrap_ALREADY_DEFINED
|
||||
#undef yywrap
|
||||
#endif
|
||||
#ifndef hsql_get_lval_ALREADY_DEFINED
|
||||
#undef yyget_lval
|
||||
#endif
|
||||
#ifndef hsql_set_lval_ALREADY_DEFINED
|
||||
#undef yyset_lval
|
||||
#endif
|
||||
#ifndef hsql_get_lloc_ALREADY_DEFINED
|
||||
#undef yyget_lloc
|
||||
#endif
|
||||
#ifndef hsql_set_lloc_ALREADY_DEFINED
|
||||
#undef yyset_lloc
|
||||
#endif
|
||||
#ifndef hsql_alloc_ALREADY_DEFINED
|
||||
#undef yyalloc
|
||||
#endif
|
||||
#ifndef hsql_realloc_ALREADY_DEFINED
|
||||
#undef yyrealloc
|
||||
#endif
|
||||
#ifndef hsql_free_ALREADY_DEFINED
|
||||
#undef yyfree
|
||||
#endif
|
||||
#ifndef hsql_text_ALREADY_DEFINED
|
||||
#undef yytext
|
||||
#endif
|
||||
#ifndef hsql_leng_ALREADY_DEFINED
|
||||
#undef yyleng
|
||||
#endif
|
||||
#ifndef hsql_in_ALREADY_DEFINED
|
||||
#undef yyin
|
||||
#endif
|
||||
#ifndef hsql_out_ALREADY_DEFINED
|
||||
#undef yyout
|
||||
#endif
|
||||
#ifndef hsql__flex_debug_ALREADY_DEFINED
|
||||
#undef yy_flex_debug
|
||||
#endif
|
||||
#ifndef hsql_lineno_ALREADY_DEFINED
|
||||
#undef yylineno
|
||||
#endif
|
||||
#ifndef hsql_tables_fload_ALREADY_DEFINED
|
||||
#undef yytables_fload
|
||||
#endif
|
||||
#ifndef hsql_tables_destroy_ALREADY_DEFINED
|
||||
#undef yytables_destroy
|
||||
#endif
|
||||
#ifndef hsql_TABLES_NAME_ALREADY_DEFINED
|
||||
#undef yyTABLES_NAME
|
||||
#endif
|
||||
|
||||
#line 213 "flex_lexer.l"
|
||||
|
||||
|
||||
#line 351 "flex_lexer.h"
|
||||
#line 735 "flex_lexer.h"
|
||||
#undef hsql_IN_HEADER
|
||||
#endif /* hsql_HEADER_H */
|
||||
|
|
|
@ -48,16 +48,6 @@ namespace hsql {
|
|||
Expr* Expr::makeOpBinary(Expr* expr1, OperatorType op, Expr* expr2) {
|
||||
Expr* e = new Expr(kExprOperator);
|
||||
e->opType = op;
|
||||
e->opChar = 0;
|
||||
e->expr = expr1;
|
||||
e->expr2 = expr2;
|
||||
return e;
|
||||
}
|
||||
|
||||
Expr* Expr::makeOpBinary(Expr* expr1, char op, Expr* expr2) {
|
||||
Expr* e = new Expr(kExprOperator);
|
||||
e->opType = kOpSimple;
|
||||
e->opChar = op;
|
||||
e->expr = expr1;
|
||||
e->expr2 = expr2;
|
||||
return e;
|
||||
|
@ -181,14 +171,6 @@ namespace hsql {
|
|||
else return name;
|
||||
}
|
||||
|
||||
bool Expr::isSimpleOp() const {
|
||||
return opType == kOpSimple;
|
||||
}
|
||||
|
||||
bool Expr::isSimpleOp(char op) const {
|
||||
return isSimpleOp() && opChar == op;
|
||||
}
|
||||
|
||||
char* substr(const char* source, int from, int to) {
|
||||
int len = to - from;
|
||||
char* copy = (char*) malloc(len + 1);;
|
||||
|
|
|
@ -37,11 +37,18 @@ namespace hsql {
|
|||
kOpCase,
|
||||
|
||||
// Binary operators.
|
||||
// Simple operators are identified by the opChar field (e.g. +, -, =, >, <).
|
||||
kOpSimple,
|
||||
kOpPlus,
|
||||
kOpMinus,
|
||||
kOpAsterisk,
|
||||
kOpSlash,
|
||||
kOpPercentage,
|
||||
kOpCaret,
|
||||
|
||||
kOpEquals,
|
||||
kOpNotEquals,
|
||||
kOpLess,
|
||||
kOpLessEq,
|
||||
kOpGreater,
|
||||
kOpGreaterEq,
|
||||
kOpLike,
|
||||
kOpNotLike,
|
||||
|
@ -51,7 +58,7 @@ namespace hsql {
|
|||
|
||||
// Unary operators.
|
||||
kOpNot,
|
||||
kOpMinus,
|
||||
kOpUnaryMinus,
|
||||
kOpIsNull,
|
||||
kOpExists
|
||||
};
|
||||
|
@ -80,7 +87,6 @@ namespace hsql {
|
|||
int64_t ival2;
|
||||
|
||||
OperatorType opType;
|
||||
char opChar;
|
||||
bool distinct;
|
||||
|
||||
|
||||
|
@ -96,19 +102,12 @@ namespace hsql {
|
|||
|
||||
const char* getName() const;
|
||||
|
||||
bool isSimpleOp() const;
|
||||
|
||||
bool isSimpleOp(char op) const;
|
||||
|
||||
|
||||
// Static constructors.
|
||||
|
||||
static Expr* make(ExprType type);
|
||||
|
||||
static Expr* makeOpUnary(OperatorType op, Expr* expr);
|
||||
|
||||
static Expr* makeOpBinary(Expr* expr1, char op, Expr* expr2);
|
||||
|
||||
static Expr* makeOpBinary(Expr* expr1, OperatorType op, Expr* expr2);
|
||||
|
||||
static Expr* makeBetween(Expr* expr, Expr* left, Expr* right);
|
||||
|
|
|
@ -63,9 +63,6 @@ namespace hsql {
|
|||
}
|
||||
|
||||
switch (expr->opType) {
|
||||
case kOpSimple:
|
||||
inprintC(expr->opChar, numIndent);
|
||||
break;
|
||||
case kOpAnd:
|
||||
inprint("AND", numIndent);
|
||||
break;
|
||||
|
|
|
@ -71,14 +71,14 @@ TEST(StatementWithParameters) {
|
|||
|
||||
ASSERT_EQ(result.parameters().size(), 2);
|
||||
|
||||
ASSERT(eq1->isSimpleOp('='))
|
||||
ASSERT_EQ(eq1->opType, hsql::kOpEquals)
|
||||
ASSERT(eq1->expr->isType(hsql::kExprColumnRef))
|
||||
ASSERT(eq1->expr2->isType(kExprParameter))
|
||||
ASSERT_EQ(eq1->expr2->ival, 0)
|
||||
ASSERT_EQ(result.parameters()[0], eq1->expr2);
|
||||
|
||||
|
||||
ASSERT(eq2->isSimpleOp('='))
|
||||
ASSERT_EQ(eq2->opType, hsql::kOpEquals)
|
||||
ASSERT(eq2->expr->isType(hsql::kExprColumnRef))
|
||||
ASSERT(eq2->expr2->isType(kExprParameter))
|
||||
ASSERT_EQ(eq2->expr2->ival, 1)
|
||||
|
|
|
@ -69,7 +69,7 @@ TEST(SelectHavingTest) {
|
|||
GroupByDescription* group = stmt->groupBy;
|
||||
ASSERT_NOTNULL(group);
|
||||
ASSERT_EQ(group->columns->size(), 1);
|
||||
ASSERT(group->having->isSimpleOp('<'));
|
||||
ASSERT_EQ(group->having->opType, kOpLess);
|
||||
ASSERT(group->having->expr->isType(kExprFunctionRef));
|
||||
ASSERT(group->having->expr2->isType(kExprLiteralFloat));
|
||||
ASSERT_EQ(group->having->expr2->fval, -2.0);
|
||||
|
@ -162,7 +162,7 @@ TEST(SelectConditionalSelectTest) {
|
|||
Expr* cond1 = where->expr;
|
||||
ASSERT_NOTNULL(cond1);
|
||||
ASSERT_NOTNULL(cond1->expr);
|
||||
ASSERT(cond1->isSimpleOp('='));
|
||||
ASSERT_EQ(cond1->opType, kOpEquals);
|
||||
ASSERT_STREQ(cond1->expr->getName(), "a");
|
||||
ASSERT(cond1->expr->isType(kExprColumnRef));
|
||||
|
||||
|
@ -203,7 +203,7 @@ TEST(SelectCaseWhen) {
|
|||
ASSERT(caseExpr->isType(kExprOperator));
|
||||
ASSERT_EQ(caseExpr->opType, kOpCase);
|
||||
ASSERT(caseExpr->expr->isType(kExprOperator));
|
||||
ASSERT(caseExpr->expr->isSimpleOp('='));
|
||||
ASSERT_EQ(caseExpr->expr->opType, kOpEquals);
|
||||
ASSERT_EQ(caseExpr->exprList->size(), 2);
|
||||
}
|
||||
|
||||
|
@ -225,7 +225,7 @@ TEST(SelectJoin) {
|
|||
|
||||
ASSERT_EQ(outer_join->right->type, kTableName);
|
||||
ASSERT_STREQ(outer_join->right->name, "Product");
|
||||
ASSERT(outer_join->condition->isSimpleOp('='));
|
||||
ASSERT_EQ(outer_join->condition->opType, kOpEquals);
|
||||
ASSERT_STREQ(outer_join->condition->expr->table, "fact");
|
||||
ASSERT_STREQ(outer_join->condition->expr->name, "product_id");
|
||||
ASSERT_STREQ(outer_join->condition->expr2->table, "Product");
|
||||
|
@ -242,7 +242,7 @@ TEST(SelectJoin) {
|
|||
ASSERT_EQ(inner_join->right->type, kTableName);
|
||||
ASSERT_STREQ(inner_join->right->name, "City");
|
||||
|
||||
ASSERT(inner_join->condition->isSimpleOp('='));
|
||||
ASSERT_EQ(inner_join->condition->opType, kOpEquals);
|
||||
ASSERT_STREQ(inner_join->condition->expr->table, "fact");
|
||||
ASSERT_STREQ(inner_join->condition->expr->name, "city_id");
|
||||
ASSERT_STREQ(inner_join->condition->expr2->table, "City");
|
||||
|
|
|
@ -75,7 +75,7 @@ TEST(UpdateStatementTest) {
|
|||
|
||||
ASSERT_NOTNULL(stmt->where);
|
||||
ASSERT(stmt->where->isType(kExprOperator));
|
||||
ASSERT(stmt->where->isSimpleOp('='));
|
||||
ASSERT_EQ(stmt->where->opType, kOpEquals);
|
||||
ASSERT_STREQ(stmt->where->expr->name, "name");
|
||||
ASSERT_STREQ(stmt->where->expr2->name, "Max Mustermann");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue