fixed inconsistend member naming. fixed building of error result in parser

This commit is contained in:
Pedro 2017-02-08 03:07:51 +01:00
parent ec46b28f32
commit 4aca7d035f
10 changed files with 291 additions and 278 deletions

View File

@ -53,4 +53,14 @@ namespace hsql {
return errorColumn_; return errorColumn_;
} }
void SQLParserResult::setIsValid(bool isValid) {
isValid_ = isValid;
}
void SQLParserResult::setErrorDetails(const char* errorMsg, int errorLine, int errorColumn) {
errorMsg_ = errorMsg;
errorLine_ = errorLine;
errorColumn_ = errorColumn;
}
} // namespace hsql } // namespace hsql

View File

@ -43,6 +43,13 @@ namespace hsql {
// Takes ownership of the statement. // Takes ownership of the statement.
void addStatement(SQLStatement* stmt); void addStatement(SQLStatement* stmt);
// Set whether parsing was successful.
void setIsValid(bool isValid);
// Set the details of the error, if available.
void setErrorDetails(const char* errorMsg, int errorLine, int errorColumn);
private: private:
// List of statements within the result. // List of statements within the result.
std::vector<SQLStatement*> statements_; std::vector<SQLStatement*> statements_;

File diff suppressed because it is too large Load Diff

View File

@ -48,7 +48,7 @@
extern int hsql_debug; extern int hsql_debug;
#endif #endif
/* "%code requires" blocks. */ /* "%code requires" blocks. */
#line 42 "bison_parser.y" /* yacc.c:1909 */ #line 40 "bison_parser.y" /* yacc.c:1909 */
// %code requires block // %code requires block
@ -209,7 +209,7 @@ extern int hsql_debug;
typedef union HSQL_STYPE HSQL_STYPE; typedef union HSQL_STYPE HSQL_STYPE;
union HSQL_STYPE union HSQL_STYPE
{ {
#line 101 "bison_parser.y" /* yacc.c:1909 */ #line 99 "bison_parser.y" /* yacc.c:1909 */
double fval; double fval;
int64_t ival; int64_t ival;

View File

@ -21,10 +21,8 @@ using namespace hsql;
int yyerror(YYLTYPE* llocp, SQLParserResult** result, yyscan_t scanner, const char *msg) { int yyerror(YYLTYPE* llocp, SQLParserResult** result, yyscan_t scanner, const char *msg) {
SQLParserResult* list = new SQLParserResult(); SQLParserResult* list = new SQLParserResult();
list->isValid = false; list->setIsValid(false);
list->errorMsg = strdup(msg); list->setErrorDetails(strdup(msg), llocp->first_line, llocp->first_column);
list->errorLine = llocp->first_line;
list->errorColumn = llocp->first_column;
*result = list; *result = list;
return 0; return 0;

View File

@ -22,7 +22,7 @@ namespace hsql {
Expr* Expr::makeOpUnary(OperatorType op, Expr* expr) { Expr* Expr::makeOpUnary(OperatorType op, Expr* expr) {
Expr* e = new Expr(kExprOperator); Expr* e = new Expr(kExprOperator);
e->op_type = op; e->opType = op;
e->expr = expr; e->expr = expr;
e->expr2 = NULL; e->expr2 = NULL;
return e; return e;
@ -30,8 +30,8 @@ namespace hsql {
Expr* Expr::makeOpBinary(Expr* expr1, OperatorType op, Expr* expr2) { Expr* Expr::makeOpBinary(Expr* expr1, OperatorType op, Expr* expr2) {
Expr* e = new Expr(kExprOperator); Expr* e = new Expr(kExprOperator);
e->op_type = op; e->opType = op;
e->op_char = 0; e->opChar = 0;
e->expr = expr1; e->expr = expr1;
e->expr2 = expr2; e->expr2 = expr2;
return e; return e;
@ -39,8 +39,8 @@ namespace hsql {
Expr* Expr::makeOpBinary(Expr* expr1, char op, Expr* expr2) { Expr* Expr::makeOpBinary(Expr* expr1, char op, Expr* expr2) {
Expr* e = new Expr(kExprOperator); Expr* e = new Expr(kExprOperator);
e->op_type = SIMPLE_OP; e->opType = SIMPLE_OP;
e->op_char = op; e->opChar = op;
e->expr = expr1; e->expr = expr1;
e->expr2 = expr2; e->expr2 = expr2;
return e; return e;
@ -114,11 +114,11 @@ namespace hsql {
} }
bool Expr::isSimpleOp() { bool Expr::isSimpleOp() {
return op_type == SIMPLE_OP; return opType == SIMPLE_OP;
} }
bool Expr::isSimpleOp(char op) { bool Expr::isSimpleOp(char op) {
return isSimpleOp() && op_char == op; return isSimpleOp() && opChar == op;
} }
char* substr(const char* source, int from, int to) { char* substr(const char* source, int from, int to) {

View File

@ -68,8 +68,8 @@ namespace hsql {
int64_t ival; int64_t ival;
int64_t ival2; int64_t ival2;
OperatorType op_type; OperatorType opType;
char op_char; char opChar;
bool distinct; bool distinct;
// Convenience accessor methods. // Convenience accessor methods.

View File

@ -32,7 +32,7 @@ namespace hsql {
virtual StatementType type() const; virtual StatementType type() const;
private: private:
StatementType _type; StatementType type_;
}; };
} // namespace hsql } // namespace hsql

View File

@ -5,12 +5,12 @@ namespace hsql {
// SQLStatement // SQLStatement
SQLStatement::SQLStatement(StatementType type) : SQLStatement::SQLStatement(StatementType type) :
_type(type) {}; type_(type) {};
SQLStatement::~SQLStatement() {} SQLStatement::~SQLStatement() {}
StatementType SQLStatement::type() const { StatementType SQLStatement::type() const {
return _type; return type_;
} }
// ColumnDefinition // ColumnDefinition

View File

@ -62,9 +62,9 @@ namespace hsql {
return; return;
} }
switch (expr->op_type) { switch (expr->opType) {
case Expr::SIMPLE_OP: case Expr::SIMPLE_OP:
inprintC(expr->op_char, numIndent); inprintC(expr->opChar, numIndent);
break; break;
case Expr::AND: case Expr::AND:
inprint("AND", numIndent); inprint("AND", numIndent);
@ -76,7 +76,7 @@ namespace hsql {
inprint("NOT", numIndent); inprint("NOT", numIndent);
break; break;
default: default:
inprintU(expr->op_type, numIndent); inprintU(expr->opType, numIndent);
break; break;
} }
printExpression(expr->expr, numIndent + 1); printExpression(expr->expr, numIndent + 1);