diff --git a/Makefile b/Makefile index 3ab260f..8504f8c 100644 --- a/Makefile +++ b/Makefile @@ -27,15 +27,17 @@ library: $(TARGET) $(TARGET): $(LIBOBJ) $(CXX) $(LIBFLAGS) -o $(TARGET) $(LIBOBJ) - %.o: %.cpp $(PARSERFILES) $(CXX) $(CFLAGS) -c -o $@ $< -$(SRCPARSER)/bison_parser.cpp: parser -$(SRCPARSER)/flex_lexer.cpp: parser +$(SRCPARSER)/bison_parser.cpp: + make -C $(SRCPARSER)/ bison_parser.cpp + +$(SRCPARSER)/flex_lexer.cpp: + make -C $(SRCPARSER)/ flex_lexer.cpp parser: - make -C $(SRCPARSER)/ + make -C $(SRCPARSER) all clean: rm -f $(TARGET) @@ -49,6 +51,8 @@ cleanall: clean cleanparser install: cp $(TARGET) $(INSTALL)/lib/$(TARGET) + cp -r src $(INSTALL)/include/hsql + find $(INSTALL)/include/hsql -not -name '*.h' -type f | xargs rm format: astyle --options=astyle.options $(ALLLIB) diff --git a/README.md b/README.md index 5f8ea54..8056e5e 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ To use the SQL parser in your own projects you simply have to follow these few s First step to extending this parser is cloning the repository `git clone git@github.com:hyrise/sql-parser.git` and making sure everything works by running the following steps: -``` +```bash make parser # builds the bison parser and flex lexer make library # builds the libsqlparser.so make test # runs the tests with the library @@ -44,7 +44,7 @@ make test # runs the tests with the library Rerun these steps whenever you change part of the parse. To execute the entire pipeline automatically you can run: -``` +```bash make cleanall # cleans the parser build and library build make test # build parser, library and runs the tests ``` diff --git a/example/example.cpp b/example/example.cpp index 91e5d17..aa17b82 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -19,6 +19,10 @@ int main(int argc, char *argv[]) { hsql::SQLParserResult* result = hsql::SQLParser::parseSQLString(query); // check whether the parsing was successful + if (!result) { + return -1; + } + if (result->isValid()) { printf("Parsed successfully!\n"); printf("Number of statements: %lu\n", result->size()); diff --git a/test/test.sh b/test/test.sh index 73b3262..b9d2dc1 100755 --- a/test/test.sh +++ b/test/test.sh @@ -32,6 +32,7 @@ fi printf "\n${GREEN}Running memory leak checks...${NC}\n" valgrind --leak-check=full --error-exitcode=200 --log-fd=3 \ ./bin/sql_tests -f "test/valid_queries.sql" 3>&1 >/dev/null 2>/dev/null +MEM_LEAK_RET=$? if [ $MEM_LEAK_RET -ne 200 ]; then printf "${GREEN}Memory leak check succeeded!${NC}\n"