HyriseSQLParser/docs/documentation.md

40 lines
1.6 KiB
Markdown
Raw Normal View History

2014-12-16 02:23:56 +01:00
Developer Documentation
=======================
2014-12-15 18:32:46 +01:00
This page contains information about how to extend this parser with new functionalities.
2014-12-16 02:23:56 +01:00
## Implementing Statement Class
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
2014-12-15 18:32:46 +01:00
## Extending the Grammar
2014-12-16 02:23:56 +01:00
Related files:
* src/parser/bison_parser.y
* src/parser/flex_lexer.l
* src/parser/keywordlist_generator.py
* src/parser/sql_keywords.txt
2014-12-15 18:32:46 +01:00
2014-12-16 02:23:56 +01:00
To extend the grammar the file you will mostly have to deal with is the bison grammar definition in src/parser/bison_parser.y.
2014-12-15 18:32:46 +01:00
2014-12-16 02:23:56 +01:00
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_stmt> example_statement`. Then you have to define the non-terminal `example_statement`. Look the other non-terminals for statements to figure out how.
2014-12-15 18:32:46 +01:00
## Implementing Tests
2014-12-16 02:23:56 +01:00
Related files:
* src/sql_tests.cpp
2014-12-15 18:32:46 +01:00