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_;
}
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

View File

@ -43,6 +43,13 @@ namespace hsql {
// Takes ownership of the statement.
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:
// List of statements within the result.
std::vector<SQLStatement*> statements_;

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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