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

PartiQL.g4 should be declared as a parser grammar #1472

Closed
kaby76 opened this issue May 28, 2024 · 2 comments
Closed

PartiQL.g4 should be declared as a parser grammar #1472

kaby76 opened this issue May 28, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@kaby76
Copy link

kaby76 commented May 28, 2024

Description

I maintain grammar-g4, the large library of Antlr4 grammars. Someone mentioned a problem with using the PartiQL grammar with the Go target. After looking at this grammar carefully, I highly recommend that you change the declaration statement of PartiQL.g4 to be parser grammar PartiQLParser;, and rename the file PartiQLParser.g4.

The problem is that PartiQL.g4 is a combined grammar, but you also declare a split grammar for the lexer, PartiQLTokens.g4. If someone adds a lexer rule, or a string literal to PartiQL.g4, a second lexer class will be generated. A parser can only reference one token stream at a time, which means it may not work as intended. Since PartiQL.g4 only contains parser rules, it should be declared as a parser grammar.

@kaby76 kaby76 added the bug Something isn't working label May 28, 2024
@RCHowell
Copy link
Contributor

Thank you very much for this issue! This is super insightful and we appreciate the advice on maintaining better grammars.

@RCHowell
Copy link
Contributor

This suggestion was merged in #1474

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants