sqlite3
sqlite3 copied to clipboard
SQL parser
We'd need a SQLite 3 SQL statements parser.
Possible candidate(s?) before writing our own:
- https://github.com/xo/usql
- https://github.com/src-d/go-mysql-server
I think it's doing just enough parsing to syntax highlight… link.
Lexer and parser generated with antlr4 for go seems to be working okay. https://github.com/antlr/antlr4/blob/master/doc/go-target.md https://github.com/antlr/grammars-v4/blob/master/sqlite/SQLite.g4 Lines 34 and 37 in the grammar file have the word 'error' which is a keyword in golang, had to change that to sqlite_error. The generated sqlite_parser.go had a statement, 'throw new RuntimeException' that I had changed to a panic.
@sri-soham: seems interesting.
I assume the way the Go code is generated, one wouldn't need anything from antlr
afterwards ?
would you be up for a PR ? :)
@sbinet : Files generated make use of the antlr go libraries. Java and the antlr jar file will not be needed though.
About the PR: I am new to lexer/parser business. It will take time.
From what I have understood, sqlite3 generates bytecode by traversing through the parse tree. That bytecode and engine are internal to sqlite3 and can change without notice. https://www.sqlite.org/opcode.html
What do I do after parse tree is built? Generate golang struct for each type of statement or something else?