Closed wengcheng003 closed 11 months ago
This is my code running under windows:
if name == 'main':
# 看仓库名称
C_LANGUAGE = Language('build/my-languages.so', 'c')
# 举一个CPP例子
c_parser = Parser()
c_parser.set_language(C_LANGUAGE)
#
c_code_snippet = '''int main(){
int wc_1 = 10;
return O;
}'''
# 没报错就是成功
tree = c_parser.parse(bytes(c_code_snippet, "utf8")) # <tree_sitter.Tree object at 0x7f1148069910>
print(tree)
# 注意,root_node 才是可遍历的树节点
root_node = tree.root_node
print(root_node)
The exe is the CLI app, and you cannot compile on Linux and expect it to work on Windows unless you know what you're doing and cross compile w/ MSVC on Linux somehow, that should be obvious. I would spend some time learning how the parser repos work and are incorporated for usage and how to actually compile stuff on windows properly, you should read the tree sitter docs for the former.
Does it work better if you name it .dll
instead of .so
?
thats not how compiled shared libraries work - and thats not a topic i can explain here in a sentence or two, sorry
A very brief TLDR to get it to just "work", compile it ON windows FOR windows runtimes, rest is on you
Thanks to everyone for their suggestions. Running python code that requires a c compiler on win10 will appear distutils. Errors. DistutilsPlatformError: Unable to find vcvarsall.bat, the solution is to install vs. It was so cumbersome that I finally gave up compiling on Windows 10.
I am a beginner and I want to use tree-sitter to parse c in python under Windows, but I can't find the documentation.
I previously generated my-languages.so under linu and used it to parse c, but it doesn't seem to read the my-languages.so file in Windows, as shown below. By the way, I found tree-sitter-windows-x86.gz in https://github.com/tree-sitter/tree-sitter/releases, and there is a tree-sitter.exe in it, I don't know what this is for.
I think there should be a way to use tree-sitter in python under Windows 10, but I haven't found it yet. If anyone can tell me, I would be very grateful!