@@ -47,10 +47,12 @@ filegroup(name = "corpus", srcs = glob(['**/corpus/*.txt']))
47
47
sha256 = sha256 ,
48
48
)
49
49
50
- def semantic_language_library (language , name , srcs , nodetypes = "" , ** kwargs ):
50
+ def semantic_language_library (language , name , srcs , ts_package = "" , nodetypes = "" , ** kwargs ):
51
51
"""Create a new library target with dependencies needed for a language-AST project."""
52
52
if nodetypes == "" :
53
53
nodetypes = "@tree-sitter-{}//:src/node-types.json" .format (language )
54
+ if ts_package == "" :
55
+ ts_package = language
54
56
haskell_library (
55
57
name = name ,
56
58
# We can't use Template Haskell to find out the location of the
@@ -63,7 +65,7 @@ def semantic_language_library(language, name, srcs, nodetypes = "", **kwargs):
63
65
'-DNODE_TYPES_PATH="../../../../$(rootpath {})"' .format (nodetypes ),
64
66
],
65
67
srcs = srcs ,
66
- extra_srcs = [nodetypes , "@tree-sitter-{}//:corpus" .format (language )],
68
+ extra_srcs = [nodetypes , "@tree-sitter-{}//:corpus" .format (ts_package )],
67
69
deps = [
68
70
"//:base" ,
69
71
"//semantic-analysis" ,
@@ -91,11 +93,15 @@ def semantic_language_library(language, name, srcs, nodetypes = "", **kwargs):
91
93
],
92
94
)
93
95
94
- def semantic_language_parsing_test (language ):
96
+ def semantic_language_parsing_test (language , semantic_package = "" , ts_package = "" ):
97
+ if semantic_package == "" :
98
+ semantic_package = language
99
+ if ts_package == "" :
100
+ ts_package = language
95
101
haskell_test (
96
102
name = "test" ,
97
103
srcs = ["test/PreciseTest.hs" ],
98
- data = ["@tree-sitter-{}//:corpus" .format (language )],
104
+ data = ["@tree-sitter-{}//:corpus" .format (ts_package )],
99
105
deps = [
100
106
":semantic-{}" .format (language ),
101
107
"//:base" ,
@@ -109,6 +115,6 @@ def semantic_language_parsing_test(language):
109
115
"@stackage//:tasty" ,
110
116
"@stackage//:tasty-hedgehog" ,
111
117
"@stackage//:tasty-hunit" ,
112
- "@stackage//:tree-sitter-" + language ,
118
+ "@stackage//:tree-sitter-" + semantic_package ,
113
119
],
114
120
)
0 commit comments