From 079162542adc6c03faae40f06be06a325f2aa4cc Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 4 Nov 2014 15:44:11 +0100 Subject: [PATCH] switched to verbose error messages --- src/build_and_run_tests.sh | 12 +++++++----- src/parser/bison_parser.y | 3 ++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/build_and_run_tests.sh b/src/build_and_run_tests.sh index 4e3370d..f46fea6 100644 --- a/src/build_and_run_tests.sh +++ b/src/build_and_run_tests.sh @@ -5,7 +5,6 @@ make clean # ./bin/tests make analysis - make grammar_test echo "\n\n" @@ -13,16 +12,19 @@ echo "\n\n" ./bin/grammar_test "SELECT a FROM foo WHERE a > 12 OR b > 3 AND c = 3 LIMIT 10" ./bin/grammar_test "SELECT col1, col2, 'test' FROM table, foo AS t WHERE age > 12 AND zipcode = 12345 GROUP BY col1;" ./bin/grammar_test "SELECT age FROM table AS t1, (SELECT * FROM table2) AS t2 ORDER BY age DESC" -./bin/grammar_test -f "SELECT * from table WHERE (b OR NOT a) AND a = 12.5 AS t1 JOIN table2 ON a = b" ./bin/grammar_test "SELECT * from table JOIN table2 ON a = b WHERE (b OR NOT a) AND a = 12.5" +./bin/grammar_test "(SELECT a FROM foo WHERE a > 12 OR b > 3 AND c = 3 LIMIT 10);" +./bin/grammar_test "SELECT t1.a, t1.b, t2.c FROM table AS t1 JOIN (SELECT * FROM foo JOIN bar ON foo.id = bar.id) t2 ON t1.a = t2.b WHERE (t1.b OR NOT t1.a) AND t2.c = 12.5" -./bin/grammar_test "(SELECT a FROM foo WHERE a > 12 OR b > 3 AND c = 3 LIMIT 10)" +# Error: Where clause in between join statement +./bin/grammar_test -f "SELECT * from table WHERE (b OR NOT a) AND a = 12.5 AS t1 JOIN table2 ON a = b" +./bin/grammar_test -f "SELECT * table WHERE (b OR NOT a) AND a = 12.5 AS t1 JOIN table2 ON a = b" echo "\n\n" # ./bin/analysis "SELECT a FROM foo WHERE a > 12 OR b > 3 AND c = 3" -./bin/analysis "SELECT col1, col2, 'test' FROM table t1, foo WHERE age > 12 AND zipcode = 12345 GROUP BY col1 ORDER BY col2 DESC LIMIT 100;" -./bin/analysis "SELECT * from table AS t1 JOIN table2 AS t2 ON t1.a = t2.b WHERE (b OR NOT a) AND a = 12.5" +# ./bin/analysis "SELECT col1, col2, 'test' FROM table t1, foo WHERE age > 12 AND zipcode = 12345 GROUP BY col1 ORDER BY col2 DESC LIMIT 100;" +# ./bin/analysis "SELECT * from table AS t1 JOIN table2 AS t2 ON t1.a = t2.b WHERE (b OR NOT a) AND a = 12.5" ./bin/analysis "SELECT t1.a, t1.b, t2.c FROM table AS t1 JOIN (SELECT * FROM foo JOIN bar ON foo.id = bar.id) t2 ON t1.a = t2.b WHERE (t1.b OR NOT t1.a) AND t2.c = 12.5" # ./bin/analysis "SELECT * from table WHERE (b OR NOT a) AND a = 12.5 JOIN table2 ON a = b" diff --git a/src/parser/bison_parser.y b/src/parser/bison_parser.y index 41d6639..b8b78f7 100644 --- a/src/parser/bison_parser.y +++ b/src/parser/bison_parser.y @@ -21,7 +21,7 @@ using namespace hsql; int yyerror(Statement **stmt, yyscan_t scanner, const char *msg) { *stmt = new Statement(kStmtError); - (*stmt)->parser_msg = msg; + (*stmt)->parser_msg = strdup(msg); return 0; } @@ -42,6 +42,7 @@ int yyerror(Statement **stmt, yyscan_t scanner, const char *msg) { %define api.prefix {hsql_} %define api.token.prefix {SQL_} +%define parse.error verbose // Specify code that is included in the generated .h and .c files %code requires {