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

SyntaxError: Can't build lexer #199

Closed
willshen99 opened this issue Jun 13, 2023 · 4 comments
Closed

SyntaxError: Can't build lexer #199

willshen99 opened this issue Jun 13, 2023 · 4 comments
Assignees

Comments

@willshen99
Copy link

Tried to run below sample code:

from simple_ddl_parser import DDLParser

parse_results = DDLParser("""create table dev.data_sync_history(
    data_sync_id bigint not null,
    sync_count bigint not null,
    sync_mark timestamp  not  null,
    sync_start timestamp  not null,
    sync_end timestamp  not null,
    message varchar(2000) null,
    primary key (data_sync_id, sync_start)
); """).run()

print(parse_results)

Received SyntaxError: Can't build lexer

ERROR: /Users/{username}/Library/Python/3.11/lib/python/site-packages/simple_ddl_parser/ddl_parser.py:155: Invalid regular expression for rule 't_AUTOINCREMENT'. global flags not at the start of the expression at position 50
Traceback (most recent call last):
  File "{scriptname}", line 3, in <module>
    parse_results = DDLParser("""create table dev.data_sync_history(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/{username}/Library/Python/3.11/lib/python/site-packages/simple_ddl_parser/parser.py", line 90, in __init__
    self.lexer = lex.lex(object=self, debug=False, debuglog=log)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/{username}/Library/Python/3.11/lib/python/site-packages/ply/lex.py", line 909, in lex
    raise SyntaxError("Can't build lexer")
SyntaxError: Can't build lexer

I have simple-ddl-parser==0.30.0 and ply==3.11 installed

@slurpyb
Copy link
Contributor

slurpyb commented Jul 16, 2023

I think it has something to do with 3.11 now enforcing global flags at the start of regex expressions. See python/cpython#91222

@max-thorpe-sains
Copy link

I also had the very same error when using simple-ddl-parser==0.30.0 and python 3.11.4. Would really love to use this python module, but can't currently.

@xnuinside xnuinside self-assigned this Aug 22, 2023
@xnuinside
Copy link
Owner

Fix was released in version 0.31.0, thanks everyone for opening the issue & PR with fix!

@xnuinside
Copy link
Owner

I also added test runner for python 3.11 on CI

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

4 participants