dearimgui / dear_bindings

C header (and language binding metadata) generator for Dear ImGui
MIT License
221 stars 12 forks source link

Error running generator #31

Closed Nairou closed 3 weeks ago

Nairou commented 1 year ago

Using Python 3.11, against Dear Imgui 1.89.2 WIP. ply claims to be installed as well.

I'm not very familiar with Python, so I don't know where to start with this error...


❯ python3 dear_bindings.py -o cimgui ../dear-imgui/imgui.h
Dear Bindings: parse Dear ImGui headers, convert to C and output metadata.
Parsing ../dear-imgui/imgui.h
ERROR: /home/nairou/dev/projects/prototypes/shipbuilder/src/support/dear_bindings/src/c_lexer.py:139: Invalid regular expression for rule 't_PRAGMA'. global flags not at the start of the expression at position 13
ERROR: /home/nairou/dev/projects/prototypes/shipbuilder/src/support/dear_bindings/src/c_lexer.py:139. Make sure '#' in rule 't_PRAGMA' is escaped with '\#'
ERROR: /home/nairou/dev/projects/prototypes/shipbuilder/src/support/dear_bindings/src/c_lexer.py:146: Invalid regular expression for rule 't_PPERROR'. global flags not at the start of the expression at position 14
ERROR: /home/nairou/dev/projects/prototypes/shipbuilder/src/support/dear_bindings/src/c_lexer.py:146. Make sure '#' in rule 't_PPERROR' is escaped with '\#'
ERROR: /home/nairou/dev/projects/prototypes/shipbuilder/src/support/dear_bindings/src/c_lexer.py:153: Invalid regular expression for rule 't_PPDEFINE'. global flags not at the start of the expression at position 15
ERROR: /home/nairou/dev/projects/prototypes/shipbuilder/src/support/dear_bindings/src/c_lexer.py:153. Make sure '#' in rule 't_PPDEFINE' is escaped with '\#'
ERROR: /home/nairou/dev/projects/prototypes/shipbuilder/src/support/dear_bindings/src/c_lexer.py:159: Invalid regular expression for rule 't_PREPROCESSOR_COMMAND'. global flags not at the start of the expression at position 27
ERROR: /home/nairou/dev/projects/prototypes/shipbuilder/src/support/dear_bindings/src/c_lexer.py:159. Make sure '#' in rule 't_PREPROCESSOR_COMMAND' is escaped with '\#'
Exception during conversion:
Traceback (most recent call last):
  File "/home/nairou/dev/projects/prototypes/shipbuilder/src/support/dear_bindings/dear_bindings.py", line 441, in <module>
    convert_header(args.src, args.output, args.templatedir)
  File "/home/nairou/dev/projects/prototypes/shipbuilder/src/support/dear_bindings/dear_bindings.py", line 69, in convert_header
    stream = c_lexer.tokenize(file_content)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nairou/dev/projects/prototypes/shipbuilder/src/support/dear_bindings/src/c_lexer.py", line 231, in tokenize
    lexer = lex.lex()
            ^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/ply/lex.py", line 909, in lex
    raise SyntaxError("Can't build lexer")
SyntaxError: Can't build lexer```
ShironekoBen commented 1 year ago

Ah, yes, sorry about that! It looks to be a problem introduced by changes to regexp handling in Python 3.11. I'll have a look at fixing it properly but it may take a few days for me to get time to do so. In the interim installing Python 3.8 and running with that should allow you to work around it, though.

Nairou commented 1 year ago

Thanks! Installing 3.8 did the trick.

ShironekoBen commented 1 year ago

OK, I've gone in and fixed the way regexp flags are set so that Python 3.11 is happy again, so if you want to use the latest version it should be working now. Thanks again for the report!