Skip to content

SQL parser #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
sbinet opened this issue Jan 18, 2018 · 5 comments
Open

SQL parser #23

sbinet opened this issue Jan 18, 2018 · 5 comments

Comments

@sbinet
Copy link
Collaborator

sbinet commented Jan 18, 2018

We'd need a SQLite 3 SQL statements parser.

Possible candidate(s?) before writing our own:

@zellyn
Copy link
Contributor

zellyn commented Jan 18, 2018

I think it's doing just enough parsing to syntax highlight… link.

@sri-soham
Copy 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.

@sbinet
Copy link
Collaborator Author

sbinet commented Apr 3, 2018

@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 ? :)

@sri-soham
Copy link

@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.

@sri-soham
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants