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

invalid syntax self.from = None in python3 generated parsers #4028

Open
chengchengpei opened this issue Dec 19, 2022 · 3 comments
Open

invalid syntax self.from = None in python3 generated parsers #4028

chengchengpei opened this issue Dec 19, 2022 · 3 comments

Comments

@chengchengpei
Copy link

chengchengpei commented Dec 19, 2022

Please include the following information

python3 antlr4 version is 4.9.3

  • smallest possible grammar and code that reproduces the behavior
import sys
import antlr4
from PrestoSqlLexer import PrestoSqlLexer
from PrestoSqlParser import PrestoSqlParser


def main():
    input_stream = antlr4.CharStream('select 1')
    lexer = PrestoSqlLexer(input_stream)
    tokens = antlr4.CommonTokenStream(lexer)
    tokens.fill()
    print([token.text for token in tokens.tokens][:-1])


if __name__ == '__main__':
    main()
  • description of the expected behavior and actual behavior
    Pointers to suspicious code regions are also very welcome.

error:

Traceback (most recent call last):
  File "/Users/clients/autocomplete/parseQuery.py", line 4, in <module>
    from PrestoSqlParser import PrestoSqlParser
  File "/Users/clients/autocomplete/PrestoSqlParser.py", line 1837
    self.from = None # QualifiedNameContext
         ^^^^
SyntaxError: invalid syntax
@ericvergnaud
Copy link
Contributor

looks like you are using a reserved keyword in you grammar rules ?

@chengchengpei
Copy link
Author

I changed to 4.11.1 and the errors gone...

@ericvergnaud
Copy link
Contributor

Please close ?

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