Skip to content
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

Can we relax the EOF and don't insist on a Semicolon #36

Open
manticore-projects opened this issue Dec 28, 2022 · 3 comments
Open

Can we relax the EOF and don't insist on a Semicolon #36

manticore-projects opened this issue Dec 28, 2022 · 3 comments

Comments

@manticore-projects
Copy link

Currently every statement MUST end with a Semicolon, or else there will be an unexpected EOF exception.
In the real world, for single statements this Semicolon is optional. Oracle JDBC even refuses to work with a trailing Semicolon.

Would it be possible to terminate a statement by ";" | <EOF> | "\n\n" for practical reasons? (Then there is GO and / ...)
Alternatively we could keep a Pure Grammar and put a Tainted Grammar beside. I love pure after all but still wait to experience it in real life.

@kaikalur
Copy link

The spec is clear that we need a semicolon. Add an flag to not need it. So the purity of the grammar is a must and any short-cut we take should be controlled by a flag.

Format
<direct SQL statement> ::=
<directly executable statement> <semicolon>
<directly executable statement> ::=
<direct SQL data statement>
| <SQL schema statement>
| <SQL transaction statement>
| <SQL connection statement>
| <SQL session statement>
| <direct implementation-defined statement>
<direct SQL data statement> ::=
<delete statement: searched>
| <direct select statement: multiple rows>
| <insert statement>
| <update statement: searched>
| <truncate table statement>
| <merge statement>
| <temporary table declaration>
<direct implementation-defined

@kaikalur
Copy link

kaikalur commented Dec 28, 2022

In case you are not familiar - JavaCC has a semantic look ahead concept. So you can add something like:

LOOKAHEAD(0, { isSemicolonNeeded() }) ";"

@kaikalur
Copy link

Actually, just add a separate rule (preferably in a separate fragment file) that simply does not have the semicolon - instead use EOF. In JavaCC, you can call any production directly so you can just call this new one

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

2 participants