From 3c69e33d5adaab2825a0f723d2d04183797f39bb Mon Sep 17 00:00:00 2001 From: Pedro Date: Fri, 31 Oct 2014 18:24:47 +0100 Subject: [PATCH] prefixed parser and lexer with hsql_ --- src/bison/SQLParser.cpp | 10 +++++----- src/bison/bison_parser.y | 7 ++++++- src/bison/flex_lexer.l | 1 + 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/bison/SQLParser.cpp b/src/bison/SQLParser.cpp index 002c2c4..17c738d 100644 --- a/src/bison/SQLParser.cpp +++ b/src/bison/SQLParser.cpp @@ -16,22 +16,22 @@ Statement* SQLParser::parseSQLString(const char *text) { yyscan_t scanner; YY_BUFFER_STATE state; - if (yylex_init(&scanner)) { + if (hsql_lex_init(&scanner)) { // couldn't initialize fprintf(stderr, "Error when initializing!\n"); return NULL; } - state = yy_scan_string(text, scanner); + state = hsql__scan_string(text, scanner); - if (yyparse(&stmt, scanner)) { + if (hsql_parse(&stmt, scanner)) { // error parsing fprintf(stderr, "Error when parsing!\n"); return NULL; } - yy_delete_buffer(state, scanner); + hsql__delete_buffer(state, scanner); - yylex_destroy(scanner); + hsql_lex_destroy(scanner); return stmt; } \ No newline at end of file diff --git a/src/bison/bison_parser.y b/src/bison/bison_parser.y index b730d02..01559c0 100644 --- a/src/bison/bison_parser.y +++ b/src/bison/bison_parser.y @@ -35,6 +35,10 @@ int yyerror(Statement **expression, yyscan_t scanner, const char *msg) { // Tell bison to create a reentrant parser %define api.pure full +// Prefix the parser +%define api.prefix {hsql_} +%define api.token.prefix {SQL_} + // Specify code that is included in the generated .h and .c files %code requires { @@ -44,6 +48,8 @@ int yyerror(Statement **expression, yyscan_t scanner, const char *msg) { typedef void* yyscan_t; #endif +#define YYSTYPE HSQL_STYPE + } // Define additional parameters for yylex (http://www.gnu.org/software/bison/manual/html_node/Pure-Calling.html) @@ -53,7 +59,6 @@ typedef void* yyscan_t; %parse-param { Statement **statement } %parse-param { yyscan_t scanner } -%define api.token.prefix {SQL_} /********************************* ** Define all data-types (http://www.gnu.org/software/bison/manual/html_node/Union-Decl.html) diff --git a/src/bison/flex_lexer.l b/src/bison/flex_lexer.l index 9e81b06..c82966f 100644 --- a/src/bison/flex_lexer.l +++ b/src/bison/flex_lexer.l @@ -37,6 +37,7 @@ %option noyywrap %option warn %option case-insensitive +%option prefix="hsql_" /* %option nodefault */