xref: /aosp_15_r20/external/emboss/compiler/front_end/BUILD (revision 99e0aae7469b87d12f0ad23e61142c2d74c1ef70)
1# Copyright 2019 Google LLC
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15# Emboss front end
16#
17# The code in this directory translates an Emboss definition file (.emb) to an
18# intermediate representation (IR).  The IR is passed to back end code
19# generators to generate code in various languages.
20
21load("@rules_python//python:py_binary.bzl", "py_binary")
22load("@rules_python//python:py_library.bzl", "py_library")
23load("@rules_python//python:py_test.bzl", "py_test")
24
25package(
26    default_visibility = [
27        "//:__subpackages__",
28    ],
29)
30
31py_library(
32    name = "tokenizer",
33    srcs = ["tokenizer.py"],
34    deps = [
35        "//compiler/util:error",
36        "//compiler/util:parser_types",
37    ],
38)
39
40py_test(
41    name = "tokenizer_test",
42    srcs = ["tokenizer_test.py"],
43    python_version = "PY3",
44    deps = [
45        ":tokenizer",
46        "//compiler/util:error",
47        "//compiler/util:parser_types",
48    ],
49)
50
51py_library(
52    name = "lr1",
53    srcs = ["lr1.py"],
54    deps = [
55        "//compiler/util:parser_types",
56    ],
57)
58
59py_test(
60    name = "lr1_test",
61    srcs = ["lr1_test.py"],
62    python_version = "PY3",
63    deps = [
64        ":lr1",
65        "//compiler/util:parser_types",
66    ],
67)
68
69py_library(
70    name = "module_ir",
71    srcs = ["module_ir.py"],
72    deps = [
73        "//compiler/util:ir_data",
74        "//compiler/util:name_conversion",
75        "//compiler/util:parser_types",
76    ],
77)
78
79py_test(
80    name = "module_ir_test",
81    srcs = ["module_ir_test.py"],
82    data = [
83        "//testdata:golden_files",
84    ],
85    python_version = "PY3",
86    deps = [
87        ":module_ir",
88        ":parser",
89        ":tokenizer",
90        "//compiler/util:ir_data",
91        "//compiler/util:test_util",
92    ],
93)
94
95py_library(
96    name = "parser",
97    srcs = ["parser.py"],
98    data = [
99        "error_examples",
100    ],
101    deps = [
102        ":lr1",
103        ":module_ir",
104        ":tokenizer",
105        "//compiler/util:resources",
106        "//compiler/util:simple_memoizer",
107    ],
108)
109
110py_test(
111    name = "parser_test",
112    srcs = ["parser_test.py"],
113    python_version = "PY3",
114    deps = [
115        ":lr1",
116        ":parser",
117        ":tokenizer",
118        "//compiler/util:parser_types",
119    ],
120)
121
122py_library(
123    name = "glue",
124    srcs = ["glue.py"],
125    data = [
126        "prelude.emb",
127    ],
128    visibility = ["//:__subpackages__"],
129    deps = [
130        ":attribute_checker",
131        ":constraints",
132        ":dependency_checker",
133        ":expression_bounds",
134        ":lr1",
135        ":module_ir",
136        ":parser",
137        ":symbol_resolver",
138        ":synthetics",
139        ":tokenizer",
140        ":type_check",
141        ":write_inference",
142        "//compiler/util:error",
143        "//compiler/util:ir_data",
144        "//compiler/util:parser_types",
145        "//compiler/util:resources",
146    ],
147)
148
149py_test(
150    name = "glue_test",
151    srcs = ["glue_test.py"],
152    data = [
153        "//testdata:golden_files",
154    ],
155    python_version = "PY3",
156    deps = [
157        ":glue",
158        "//compiler/util:error",
159        "//compiler/util:ir_data",
160        "//compiler/util:parser_types",
161        "//compiler/util:test_util",
162    ],
163)
164
165py_library(
166    name = "synthetics",
167    srcs = ["synthetics.py"],
168    visibility = ["//visibility:private"],
169    deps = [
170        "//compiler/util:expression_parser",
171        "//compiler/util:ir_data",
172        "//compiler/util:traverse_ir",
173    ],
174)
175
176py_test(
177    name = "synthetics_test",
178    srcs = ["synthetics_test.py"],
179    python_version = "PY3",
180    deps = [
181        ":glue",
182        ":synthetics",
183        "//compiler/util:test_util",
184    ],
185)
186
187py_library(
188    name = "symbol_resolver",
189    srcs = ["symbol_resolver.py"],
190    visibility = ["//visibility:private"],
191    deps = [
192        "//compiler/util:error",
193        "//compiler/util:ir_data",
194        "//compiler/util:ir_util",
195        "//compiler/util:traverse_ir",
196    ],
197)
198
199py_test(
200    name = "symbol_resolver_test",
201    srcs = ["symbol_resolver_test.py"],
202    python_version = "PY3",
203    deps = [
204        ":glue",
205        ":symbol_resolver",
206        "//compiler/util:error",
207        "//compiler/util:test_util",
208    ],
209)
210
211py_library(
212    name = "write_inference",
213    srcs = ["write_inference.py"],
214    visibility = ["//visibility:private"],
215    deps = [
216        ":attributes",
217        ":expression_bounds",
218        "//compiler/util:ir_data",
219        "//compiler/util:ir_util",
220        "//compiler/util:traverse_ir",
221    ],
222)
223
224py_test(
225    name = "write_inference_test",
226    srcs = ["write_inference_test.py"],
227    python_version = "PY3",
228    deps = [
229        ":glue",
230        ":write_inference",
231        "//compiler/util:ir_data",
232        "//compiler/util:test_util",
233    ],
234)
235
236py_library(
237    name = "attribute_checker",
238    srcs = ["attribute_checker.py"],
239    deps = [
240        ":attributes",
241        ":type_check",
242        "//compiler/util:attribute_util",
243        "//compiler/util:error",
244        "//compiler/util:ir_data",
245        "//compiler/util:ir_util",
246        "//compiler/util:traverse_ir",
247    ],
248)
249
250py_library(
251    name = "attributes",
252    srcs = ["attributes.py"],
253    deps = [],
254)
255
256py_test(
257    name = "attribute_checker_test",
258    timeout = "long",
259    srcs = ["attribute_checker_test.py"],
260    python_version = "PY3",
261    deps = [
262        ":attribute_checker",
263        ":glue",
264        "//compiler/util:error",
265        "//compiler/util:ir_data",
266        "//compiler/util:ir_util",
267        "//compiler/util:test_util",
268    ],
269)
270
271py_library(
272    name = "type_check",
273    srcs = ["type_check.py"],
274    deps = [
275        ":attributes",
276        "//compiler/util:error",
277        "//compiler/util:ir_data",
278        "//compiler/util:ir_util",
279        "//compiler/util:traverse_ir",
280    ],
281)
282
283py_test(
284    name = "type_check_test",
285    srcs = ["type_check_test.py"],
286    python_version = "PY3",
287    deps = [
288        ":glue",
289        ":type_check",
290        "//compiler/util:error",
291        "//compiler/util:test_util",
292    ],
293)
294
295py_library(
296    name = "expression_bounds",
297    srcs = ["expression_bounds.py"],
298    data = [
299        "reserved_words",
300    ],
301    deps = [
302        ":attributes",
303        "//compiler/util:ir_data",
304        "//compiler/util:ir_util",
305        "//compiler/util:traverse_ir",
306    ],
307)
308
309py_test(
310    name = "expression_bounds_test",
311    srcs = ["expression_bounds_test.py"],
312    python_version = "PY3",
313    deps = [
314        ":expression_bounds",
315        ":glue",
316        "//compiler/util:test_util",
317    ],
318)
319
320py_library(
321    name = "constraints",
322    srcs = ["constraints.py"],
323    data = [
324        "reserved_words",
325    ],
326    deps = [
327        ":attributes",
328        "//compiler/util:error",
329        "//compiler/util:ir_data",
330        "//compiler/util:ir_util",
331        "//compiler/util:resources",
332        "//compiler/util:traverse_ir",
333    ],
334)
335
336py_test(
337    name = "constraints_test",
338    srcs = ["constraints_test.py"],
339    python_version = "PY3",
340    deps = [
341        ":constraints",
342        ":glue",
343        "//compiler/util:error",
344        "//compiler/util:test_util",
345    ],
346)
347
348py_library(
349    name = "dependency_checker",
350    srcs = ["dependency_checker.py"],
351    deps = [
352        "//compiler/util:error",
353        "//compiler/util:ir_data",
354        "//compiler/util:ir_util",
355        "//compiler/util:traverse_ir",
356    ],
357)
358
359py_test(
360    name = "dependency_checker_test",
361    srcs = ["dependency_checker_test.py"],
362    python_version = "PY3",
363    deps = [
364        ":dependency_checker",
365        ":glue",
366        "//compiler/util:error",
367        "//compiler/util:test_util",
368    ],
369)
370
371py_binary(
372    name = "emboss_front_end",
373    srcs = ["emboss_front_end.py"],
374    python_version = "PY3",
375    visibility = ["//visibility:public"],
376    deps = [
377        ":glue",
378        ":module_ir",
379        "//compiler/util:error",
380    ],
381)
382
383py_binary(
384    name = "format",
385    srcs = ["format.py"],
386    main = "format.py",
387    python_version = "PY3",
388    visibility = ["//visibility:public"],
389    deps = [
390        ":format_emb",
391        ":parser",
392        ":tokenizer",
393        "//compiler/util:error",
394    ],
395)
396
397py_library(
398    name = "format_emb",
399    srcs = ["format_emb.py"],
400    deps = [
401        ":module_ir",
402        ":tokenizer",
403        "//compiler/util:parser_types",
404    ],
405)
406
407py_test(
408    name = "format_emb_test",
409    srcs = ["format_emb_test.py"],
410    data = [
411        "//testdata:format_embs",
412    ],
413    python_version = "PY3",
414    deps = [
415        ":format_emb",
416        ":module_ir",
417        ":parser",
418        ":tokenizer",
419    ],
420)
421
422py_binary(
423    name = "generate_grammar_md",
424    srcs = ["generate_grammar_md.py"],
425    python_version = "PY3",
426    deps = [
427        ":constraints",
428        ":module_ir",
429        ":tokenizer",
430    ],
431)
432
433py_test(
434    name = "docs_are_up_to_date_test",
435    srcs = ["docs_are_up_to_date_test.py"],
436    data = [
437        "//doc:grammar_md",
438    ],
439    python_version = "PY3",
440    deps = [
441        ":generate_grammar_md",
442    ],
443)
444