You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you very much for your cooperation ! Cooperation for you to implement DDL is not spare. So, please ask me anything you do not understand.
The following outlines the steps for implementing DDL.
First of all, I think that the implementation starts from the point of defining the syntax of DDL. I used only DML statements as a reference from the grammar definitions published in sqlite-parser. After that, I added and changed the grammar so that I could cope with other DBMS to some extent. So the syntax of sqlite-parser may be helpful.
Next, create a class that inherits from the Node class for Statements and its lower level grammar elements. This class is a class that generates each node of Syntax tree output by miniSqlParser. It is necessary to determine which grammar element to make a class.
Next, use the Antlr4 to generate a parser and a lexer code from the defined grammar.
Next, create a callback function called from the parser in MakeASTListener.cs (and MakeASTListener_Expr.cs, MakeASTListener_Predicate.cs). These functions correspond to individual grammar elements. When a SQL statement is parsed, if a grammar element is found, the corresponding function is called.
The function creates an object from the class corresponding to the grammar element and puts it on the stack (MakeASTListener._stack). In the callback function of the upper grammar element, Pop out the object pushed by the callback function of the lower grammar element, store the fetched object in the object corresponding to the upper grammar element and push it.
Support DDL.
Currently library does not support DDL part of sql. I would like to try partially implement ddl functionality.
Grammar to implement in that issue:
// DDL
ddl_stmt
: create_stmt
| alter_stmt
| drop_stmt;
create_stmt
: create_table_stmt
| create_index_stmt
| create_sequence_stmt
| create_procedure_stmt
| create_view_stmt
| create_trigger_stmt
;
alter_stmt:
alter_table_stmt
;
drop_stmt
: drop_index_stmt
| drop_table_stmt
| drop_trigger_stmt
| drop_view_stmt
;
I think it would be great to start from that limited grammar.
The text was updated successfully, but these errors were encountered: