Scony / godot-gdscript-toolkit

Independent set of GDScript tools - parser, linter, formatter, and more
MIT License
983 stars 68 forks source link

`gdradon`: KeyError: Token('RULE', 'property_body_def') with Property Body #292

Closed plink-plonk-will closed 6 months ago

plink-plonk-will commented 6 months ago

When running gdradon cc on a GDScript with a Property definition in it, the gd2py convertor throws an exception:

Traceback (most recent call last):
  File "Python/3.9/bin/gd2py", line 8, in <module>
    sys.exit(main())
  File "Python/3.9/lib/python/site-packages/gdtoolkit/gd2py/__main__.py", line 34, in main
    print(convert_code(handle.read()))
  File "Python/3.9/lib/python/site-packages/gdtoolkit/gd2py/__init__.py", line 24, in convert_code
    converted_lines = _convert_block(parse_tree.children, context)
  File "Python/3.9/lib/python/site-packages/gdtoolkit/gd2py/__init__.py", line 31, in _convert_block
    converted_lines += _convert_statement(statement, context)
  File "Python/3.9/lib/python/site-packages/gdtoolkit/gd2py/__init__.py", line 115, in _convert_statement
    return handlers[statement.data](statement, context)
KeyError: Token('RULE', 'property_body_def')

I am happy to open a PR with this if preferred, but I patched this locally by passing it in the statement conversion in gdtoolkit/gd2py/__init__.py _convert_statement, eg:

        ...
        "enum_stmt": _pass,  # TODO: implement
        "classname_stmt": _pass,
        "property_body_def": _pass, # This was added here
        "classname_extends_stmt": _pass,
        "signal_stmt": _pass, 
        ...
Scony commented 6 months ago

Yeah, the gd2py is probably quite outdated. If you'd like to open PR I'd be happy to accept that.