DouDou commited on
Commit
a38d186
·
verified ·
1 Parent(s): 9db41d1

Upload data2/step22/debug_parser.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. data2/step22/debug_parser.py +25 -0
data2/step22/debug_parser.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ from tree_sitter import Language, Parser
3
+ import os
4
+
5
+ LANG_SO = "build/my-languages.so"
6
+ LANGUAGES = ["python", "c", "cpp", "java", "go", "rust", "julia"]
7
+
8
+ def test_load():
9
+ print(f"CWD: {os.getcwd()}")
10
+ print(f"LANG_SO path: {os.path.abspath(LANG_SO)}")
11
+ print(f"Exists: {os.path.exists(LANG_SO)}")
12
+
13
+ for lang in LANGUAGES:
14
+ try:
15
+ language = Language(LANG_SO, lang)
16
+ parser = Parser()
17
+ parser.set_language(language)
18
+ print(f"Successfully loaded {lang}")
19
+ except Exception as e:
20
+ print(f"Failed to load {lang}: {e}")
21
+ import traceback
22
+ traceback.print_exc()
23
+
24
+ if __name__ == "__main__":
25
+ test_load()