From 38e480ec0e98a1e9faae2465745b63738043c337 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 16 Dec 2014 02:23:56 +0100 Subject: [PATCH] updated documenation --- README.md | 30 +++++++----------------------- docs/documentation.md | 34 ++++++++++++++++++++++++++-------- docs/doxy.conf | 6 ++++++ docs/integration.md | 9 +++++++++ docs/issues.md | 11 +++++++++++ 5 files changed, 59 insertions(+), 31 deletions(-) create mode 100644 docs/integration.md create mode 100644 docs/issues.md diff --git a/README.md b/README.md index f21f59e..185fe29 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -SQL Parser (C++) -========== +C++ SQL Parser for Hyrise +========================= This is a SQL Parser for C++. It parses the given SQL query into C++ objects. It is developed for integration in hyrise (https://github.com/hyrise/hyrise), but can be used in other environments as well. @@ -14,26 +14,10 @@ To create the full parser code run `make build`. The parser library code is crea To use the SQL Parser in your own code, you only need to include `SQLParser.h` and build+link all the source files from the parser with your project. See `hyrise/src/lib/access/sql/SQLQueryParser.cpp` for how it's used in Hyrise. -### Run tests +**Important:** Execute all tests by calling `make test`. -To execute all tests run: `./run_tests.sh`. +### Documentation -### Update in Hyrise - -Run `./deploy_to_hyris.sh path/to/hyrise` to update the SQL parser within Hyrise. - -### Capabilities (Can and Can't do) - -**Can** - * Single select statements - * Join expressions - * Create tables - * Insert statements - * Delete/Truncate statements - -**Can't (yet)** - * Having clause - * Update statements - * Union clauses - * Create anything other than tables - * Alter/Rename statements +* [Developer Documentation](docs/documentation.md) +* [Integration in Hyrise](docs/integration.md) +* [Known Issues](docs/issues.md) \ No newline at end of file diff --git a/docs/documentation.md b/docs/documentation.md index 1cf9add..7cb9edb 100644 --- a/docs/documentation.md +++ b/docs/documentation.md @@ -1,21 +1,39 @@ -# Developer Documentation +Developer Documentation +======================= This page contains information about how to extend this parser with new functionalities. -## Extending the Grammar - -TODO - - ## Implementing Statement Class -TODO +Create a new file and class in src/lib/statements/ or extend any of the existing Statements. Every statement needs to have the base class SQLStatement and needs to call its super constructor with its type. If your defining a new statement type, you need to define a new StatementType in SQLStatement.h. + +It is important that you create an appropriate constructor for your statement that zero-initializes all its pointer variables and that your create an appropriate destructor. + +Lastly you need to include your new file in src/lib/sqllib.h + + + +## Extending the Grammar + +Related files: + * src/parser/bison_parser.y + * src/parser/flex_lexer.l + * src/parser/keywordlist_generator.py + * src/parser/sql_keywords.txt + +To extend the grammar the file you will mostly have to deal with is the bison grammar definition in src/parser/bison_parser.y. + +If your extending an existing statement, skip to the non-terminal definition for that statement. I.e. for an InsertStatement the non-terminal insert_statement. + +If your defining a new statement, you will need to define your type in the \%union directive `hsql::ExampleStatement example_stmt`. Next you need to associate this type with a non-terminal `\%type example_statement`. Then you have to define the non-terminal `example_statement`. Look the other non-terminals for statements to figure out how. + ## Implementing Tests -TODO +Related files: + * src/sql_tests.cpp diff --git a/docs/doxy.conf b/docs/doxy.conf index 5261ee5..4ea6b16 100644 --- a/docs/doxy.conf +++ b/docs/doxy.conf @@ -4,10 +4,16 @@ @GENERATE_LATEX = NO @GENERATE_HTML = YES +@INCLUDE_FILE_PATTERNS = *.y *.l +@FILE_PATTERNS = *.y *.l *.h *.cpp *.md + + @INPUT = README.md \ docs/ \ src/parser/SQLParser.h \ src/parser/SQLParser.cpp \ + src/parser/bison_parser.y \ + src/parser/flex_lexer.l \ src/lib/ \ diff --git a/docs/integration.md b/docs/integration.md new file mode 100644 index 0000000..84cfe78 --- /dev/null +++ b/docs/integration.md @@ -0,0 +1,9 @@ +Integration in Hyrise +===================== + + + + +## Update the Parser in Hyrise + +Run `./deploy_to_hyrise.sh path/to/hyrise` to update the SQL parser code within Hyrise. \ No newline at end of file diff --git a/docs/issues.md b/docs/issues.md new file mode 100644 index 0000000..9154abb --- /dev/null +++ b/docs/issues.md @@ -0,0 +1,11 @@ +Known Issues +============ + + + +## Missing Functionality + + * Having clause + * Union clauses + * Create anything other than tables + * Alter/Rename statements