Registry / serialization / tree-sitter-objc

tree-sitter-objc

JSON →
library3.0.2pypypi✓ verified 85d ago

Objective-C grammar for tree-sitter (v3.0.2). Parses Objective-C and Objective-C++ source code into a concrete syntax tree. Requires Python >=3.9.

pip install tree-sitter-objc
INSTALL
IMPORT
SIG · TREE-SITTER-OBJC
T
tree-sitter-objc
serializationpythonv3.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Language
from tree_sitter_objc import language
from tree_sitter_objc import Language
The correct import is the function 'language', not a class 'Language' directly.

Minimal example: load the grammar, parse ObjC code, and print the syntax tree.

from tree_sitter import Language, Parser # Load the Objective-C grammar (v3.0.2) ObjCLanguage = Language('tree_sitter_objc', 'objc') parser = Parser() parser.set_language(ObjCLanguage) # Parse a simple Objective-C snippet source = b""" #import <Foundation/Foundation.h> @interface MyClass : NSObject - (void)sayHello; @end """ tree = parser.parse(source) print(tree.root_node.sexp())
Debug
Known issues
breakingv3.0.0+ switched from a direct 'Language' class to a 'language()' function. The grammar is loaded via tree-sitter's Language constructor using the module name.
fix
Use 'from tree_sitter_objc import language' and pass it to Language() or use Language('tree_sitter_objc', 'objc').
affects: >=3.0.0
gotchaThe grammar module name is 'tree_sitter_objc' but the language name is 'objc'. Do not confuse these.
fix
When using Language('tree_sitter_objc', 'objc'), the second argument is the language name, not the module name.
affects: all
deprecatedPython 3.8 and earlier are not supported. Requires Python >=3.9.
fix
Upgrade Python to 3.9 or later.
affects: >=3.0.0
Errors
Common errors & fixes
ImportError: cannot import name 'Language' from 'tree_sitter_objc'
Incorrect import: trying to import a class 'Language' that does not exist.
fix
Use 'from tree_sitter_objc import language' or 'from tree_sitter import Language'.
AttributeError: module 'tree_sitter_objc' has no attribute 'language'
Outdated version of tree-sitter-objc (before v3.0.0) or the grammar wasn't properly installed.
fix
Install the latest version: pip install --upgrade tree-sitter-objc.
ValueError: Unknown language 'objc'
The language name passed to Language() doesn't match the registered grammar.
fix
Use 'objc' (not 'objective-c' or 'objc++') for the language name.
Upgrade
Version history
3.0.2latest on PyPI · released Dec 16, 2024
Audit
Dependencies
tree-sitterrequiredRuntime dependency for language bindings
Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources
tree-sitter-objc — pip install tree-sitter-objc · libregistry