wenkokke / py-tree-sitter-type-provider

Type providers for tree-sitter in Python.
MIT License
3 stars 1 forks source link

`error_as_node` param used in README example doesn't exist #94

Closed smheidrich closed 1 week ago

smheidrich commented 1 week ago

The README's example snippet contains

tstp.TreeSitterTypeProvider(
    "tree_sitter_javascript",
    node_types,
    error_as_node=True,          # Include ERROR as a node in the AST
    as_class_name=as_class_name, # How to convert node types to Python class names
    extra=["comment"],           # Nodes which are marked as 'extra' in the grammar
)

But error_as_node doesn't seem to exist (anymore) as a TreeSitterTypeProvider constructor parameter:

https://github.com/wenkokke/py-tree-sitter-type-provider/blob/38ffa6de375f4775ad9caa9b916490d4f7ad066c/src/tree_sitter_type_provider/__init__.py#L247-L256

wenkokke commented 1 week ago

Woops. I think having errors as nodes is the only supported behavior now, since this is how tree sitter parsers work.

The code on line 277 adds an ERROR node unconditionally. The parsing functions take a "raise parse error" parameter instead now.