namespaced the library in namespace hsql
This commit is contained in:
		
							parent
							
								
									3c69e33d5a
								
							
						
					
					
						commit
						c1c5fba762
					
				| @ -3,9 +3,11 @@ | |||||||
| #include "flex_lexer.h" | #include "flex_lexer.h" | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| 
 | 
 | ||||||
| int yyparse(Statement **expression, yyscan_t scanner); | // int yyparse(Statement **expression, yyscan_t scanner);
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | namespace hsql { | ||||||
|  | 
 | ||||||
| SQLParser::SQLParser() { | SQLParser::SQLParser() { | ||||||
| 	fprintf(stderr, "SQLParser only has static methods atm! Do not initialize!\n"); | 	fprintf(stderr, "SQLParser only has static methods atm! Do not initialize!\n"); | ||||||
| } | } | ||||||
| @ -35,3 +37,5 @@ Statement* SQLParser::parseSQLString(const char *text) { | |||||||
|     hsql_lex_destroy(scanner); |     hsql_lex_destroy(scanner); | ||||||
|     return stmt; |     return stmt; | ||||||
| } | } | ||||||
|  |      | ||||||
|  | } // namespace hsql
 | ||||||
| @ -4,6 +4,8 @@ | |||||||
| #include "Statement.h" | #include "Statement.h" | ||||||
| #include "bison_parser.h" | #include "bison_parser.h" | ||||||
| 
 | 
 | ||||||
|  | namespace hsql { | ||||||
|  | 
 | ||||||
| class SQLParser { | class SQLParser { | ||||||
| public: | public: | ||||||
| 	static Statement* parseSQLString(const char* sql); | 	static Statement* parseSQLString(const char* sql); | ||||||
| @ -13,5 +15,7 @@ private: | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| 	 | 	 | ||||||
|  | } // namespace hsql
 | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| #endif | #endif | ||||||
| @ -17,6 +17,8 @@ | |||||||
| 
 | 
 | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| 
 | 
 | ||||||
|  | using namespace hsql; | ||||||
|  | 
 | ||||||
| int yyerror(Statement **expression, yyscan_t scanner, const char *msg) { | int yyerror(Statement **expression, yyscan_t scanner, const char *msg) { | ||||||
| 	fprintf(stderr, "[Error] SQL Parser: %s\n", msg); | 	fprintf(stderr, "[Error] SQL Parser: %s\n", msg); | ||||||
| 	return 0; | 	return 0; | ||||||
| @ -56,7 +58,7 @@ typedef void* yyscan_t; | |||||||
| %lex-param   { yyscan_t scanner } | %lex-param   { yyscan_t scanner } | ||||||
| 
 | 
 | ||||||
| // Define additional parameters for yyparse | // Define additional parameters for yyparse | ||||||
| %parse-param { Statement **statement } | %parse-param { hsql::Statement **statement } | ||||||
| %parse-param { yyscan_t scanner } | %parse-param { yyscan_t scanner } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -69,17 +71,17 @@ typedef void* yyscan_t; | |||||||
| 	char* sval; | 	char* sval; | ||||||
| 	uint uval; | 	uint uval; | ||||||
| 
 | 
 | ||||||
| 	Statement* statement; | 	hsql::Statement* statement; | ||||||
| 	SelectStatement* select_statement; | 	hsql::SelectStatement* select_statement; | ||||||
| 	TableRef* table; | 	hsql::TableRef* table; | ||||||
| 	Expr* expr; | 	hsql::Expr* expr; | ||||||
| 	OrderDescription* order; | 	hsql::OrderDescription* order; | ||||||
| 	OrderType order_type; | 	hsql::OrderType order_type; | ||||||
| 	LimitDescription* limit; | 	hsql::LimitDescription* limit; | ||||||
| 
 | 
 | ||||||
| 	List<char*>* slist; | 	hsql::List<char*>* slist; | ||||||
| 	List<Expr*>* explist; | 	hsql::List<hsql::Expr*>* explist; | ||||||
| 	List<TableRef*>* tbllist; | 	hsql::List<hsql::TableRef*>* tbllist; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -3,6 +3,8 @@ | |||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
| 
 | 
 | ||||||
|  | namespace hsql { | ||||||
|  | 
 | ||||||
| char* substr(const char* source, int from, int to) { | char* substr(const char* source, int from, int to) { | ||||||
| 	int len = to-from; | 	int len = to-from; | ||||||
| 	char* copy = new char[len+1]; | 	char* copy = new char[len+1]; | ||||||
| @ -76,3 +78,5 @@ Expr* Expr::makeFunctionRef(char* func_name, Expr* expr) { | |||||||
| 	e->expr = expr; | 	e->expr = expr; | ||||||
| 	return e; | 	return e; | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | } // namespace hsql
 | ||||||
| @ -3,6 +3,8 @@ | |||||||
| 
 | 
 | ||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
| 
 | 
 | ||||||
|  | namespace hsql { | ||||||
|  | 
 | ||||||
| typedef enum { | typedef enum { | ||||||
| 	kExprLiteralFloat, | 	kExprLiteralFloat, | ||||||
| 	kExprLiteralString, | 	kExprLiteralString, | ||||||
| @ -75,4 +77,6 @@ struct Expr { | |||||||
| 		*var = zero;				\ | 		*var = zero;				\ | ||||||
| 	} while(0) | 	} while(0) | ||||||
| 
 | 
 | ||||||
|  | } // namespace hsql
 | ||||||
|  | 
 | ||||||
| #endif | #endif | ||||||
|  | |||||||
| @ -4,6 +4,8 @@ | |||||||
| #include <vector> | #include <vector> | ||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
| 
 | 
 | ||||||
|  | namespace hsql { | ||||||
|  | 
 | ||||||
| // TODO: try to replace the List wrapper by directly using std::vector
 | // TODO: try to replace the List wrapper by directly using std::vector
 | ||||||
| 
 | 
 | ||||||
| template <typename _T> | template <typename _T> | ||||||
| @ -25,4 +27,6 @@ public: | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | } // namespace hsql
 | ||||||
|  | 
 | ||||||
| #endif | #endif | ||||||
|  | |||||||
| @ -9,6 +9,7 @@ | |||||||
| #include "List.h" | #include "List.h" | ||||||
| #include "Table.h" | #include "Table.h" | ||||||
| 
 | 
 | ||||||
|  | namespace hsql { | ||||||
| 
 | 
 | ||||||
| typedef enum { | typedef enum { | ||||||
| 	kStmtSelect, | 	kStmtSelect, | ||||||
| @ -93,5 +94,6 @@ struct CreateStatement : Statement { | |||||||
| 	// TODO
 | 	// TODO
 | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | } // namespace hsql
 | ||||||
| 
 | 
 | ||||||
| #endif // __STATEMENT_H__
 | #endif // __STATEMENT_H__
 | ||||||
|  | |||||||
| @ -1,6 +1,9 @@ | |||||||
| #ifndef __TABLEREF_H__ | #ifndef __TABLEREF_H__ | ||||||
| #define __TABLEREF_H__ | #define __TABLEREF_H__ | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  | namespace hsql { | ||||||
|  | 
 | ||||||
| class SelectStatement; | class SelectStatement; | ||||||
| class JoinStatement; | class JoinStatement; | ||||||
| 
 | 
 | ||||||
| @ -29,5 +32,6 @@ struct TableRef { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | } // namespace hsql
 | ||||||
| 
 | 
 | ||||||
| #endif | #endif | ||||||
|  | |||||||
| @ -3,6 +3,8 @@ | |||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| #include <string> | #include <string> | ||||||
| 
 | 
 | ||||||
|  | namespace hsql { | ||||||
|  | 
 | ||||||
| void printExpression(Expr* expr, uint num_indent); | void printExpression(Expr* expr, uint num_indent); | ||||||
| void printOperatorExpression(Expr* expr, uint num_indent); | void printOperatorExpression(Expr* expr, uint num_indent); | ||||||
| 
 | 
 | ||||||
| @ -68,3 +70,6 @@ void printSelectStatementInfo(SelectStatement* stmt, uint num_indent) { | |||||||
|   } else inprint("null", num_indent+2); |   } else inprint("null", num_indent+2); | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | } // namespace hsql
 | ||||||
| @ -5,7 +5,10 @@ | |||||||
| 
 | 
 | ||||||
| #include "Statement.h" | #include "Statement.h" | ||||||
| 
 | 
 | ||||||
|  | namespace hsql { | ||||||
|  | 
 | ||||||
| void printSelectStatementInfo(SelectStatement* stmt, uint num_indent); | void printSelectStatementInfo(SelectStatement* stmt, uint num_indent); | ||||||
| 
 | 
 | ||||||
|  | } // namespace hsql
 | ||||||
| 
 | 
 | ||||||
| #endif | #endif | ||||||
| @ -4,6 +4,8 @@ | |||||||
| #include "lib/sqlhelper.h" | #include "lib/sqlhelper.h" | ||||||
| #include "SQLParser.h" | #include "SQLParser.h" | ||||||
| 
 | 
 | ||||||
|  | using namespace hsql; | ||||||
|  | 
 | ||||||
| int main(int argc, char *argv[]) { | int main(int argc, char *argv[]) { | ||||||
|     if (argc <= 1) { |     if (argc <= 1) { | ||||||
|         fprintf(stderr, "No SQL-Statement given!\n"); |         fprintf(stderr, "No SQL-Statement given!\n"); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Pedro
						Pedro