-
Notifications
You must be signed in to change notification settings - Fork 10
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
Online yacc/lex grammar editor/tester #36
Comments
Maybe, but there is https://github.com/ricomariani/CG-SQL-author that is a superset of sqlite that you can also try online here https://mingodad.github.io/CG-SQL-Lua-playground/ and the grammar is there with this name |
As expected, it doesn't work: CREATE TABLE test (view TEXT); -- view fallbacks to ID instead of keyword gives
And CREATE VIRTUAL TABLE t3 using fts5(a,b,c); -- a,b,c are wildcards gives
|
Thank you for pointing it out !
You can see that the authors of In the case of |
I just added a partially working sqlite3 grammar converting the original parser using the changes I made to
Then added the lexer part by hand. It doesn't handle On https://mingodad.github.io/parsertl-playground/playground/ select |
One big regret I have from building CQL is that I didn't just start from the SQLite grammar. My life would have been so much simpler... We started from some mysql and it was good enough for us but then getting more of the grammar in place became harder and harder. Oh well, that ship has sailed. Note that CG/SQL grammar is not a strict superset of SQLite. It's a venn diagram. For instance, CQL does not and cannot reasonably support column names that are not valid identifiers. And it's stricter in many areas. But it does support some useful sugar that isn't in the original. |
Oh I should add, because CQL uses yacc we get LALR(1) and that means some fallbacks that SQLite could do, we can't. A few other choices were made to avoid shift/reduce conflicts. The grammar is pretty good but I would never call it a superset. The presence of keywords is crucial for ambiguity removal and indeed if you added a lot of names as ids you could find the grammar in a bad state. |
One other thing. CG/SQL departs significantly from SQLite on virtual tables because it can't do its job at all unless it knows the datatypes of the columns in the virtual table -- it offers strict typing. So there is totally new syntax for specifying the types of the columns as well as the module. |
Could be made to work I think but you need to tell it the shape of the resulting table. CG/SQL doesn't care about virtual tables other than it needs to know what columns they have. e.g.
Note the then you can do
|
Hello @ricomariani ! |
FWIW I just added "add" and "view" to the allow list. That didn't cause any conflicts. So you could just pull again. And you're welcome :D |
I'm trying to build an online yacc/lex (LALR(1)) grammar editor/tester to help develop/debug/document grammars the main repository is here https://github.com/mingodad/parsertl-playground and the online playground with several non trivial examples is here https://mingodad.github.io/parsertl-playground/playground/ .
Select a grammar/example from "Examples" select box and then click "Parse" to see a parser tree for the source in "Input source" editor.
It's based on https://github.com/BenHanson/gram_grep and https://github.com/BenHanson/lexertl14 .
Any feedback is welcome !
The grammars available so far (with varying state of correctness):
The text was updated successfully, but these errors were encountered: