BUILD 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. # Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. # Exceptions. See /LICENSE for license information.
  3. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. load("@mypy_integration//:mypy.bzl", "mypy_test")
  5. package(default_visibility = [
  6. "//executable_semantics:__pkg__",
  7. "//executable_semantics/fuzzing:__pkg__",
  8. ])
  9. cc_library(
  10. name = "bison_wrap",
  11. hdrs = ["bison_wrap.h"],
  12. deps = ["//common:check"],
  13. )
  14. cc_test(
  15. name = "parse_test",
  16. srcs = ["parse_test.cpp"],
  17. deps = [
  18. ":syntax",
  19. "//common:gtest_main",
  20. "//executable_semantics/common:arena",
  21. "@com_google_googletest//:gtest",
  22. ],
  23. )
  24. cc_library(
  25. name = "parse_test_matchers",
  26. testonly = 1,
  27. srcs = ["parse_test_matchers_internal.h"],
  28. hdrs = ["parse_test_matchers.h"],
  29. deps = [
  30. ":syntax",
  31. "@com_google_googletest//:gtest",
  32. "@llvm-project//llvm:Support",
  33. ],
  34. )
  35. cc_library(
  36. name = "prelude",
  37. srcs = ["prelude.cpp"],
  38. hdrs = ["prelude.h"],
  39. data = ["//executable_semantics:standard_libraries"],
  40. deps = [
  41. ":syntax",
  42. "//common:error",
  43. "//executable_semantics/ast:declaration",
  44. "//executable_semantics/common:arena",
  45. "//executable_semantics/common:nonnull",
  46. ],
  47. )
  48. cc_library(
  49. name = "syntax",
  50. srcs = [
  51. "lexer.cpp",
  52. "lexer.h",
  53. "parse.cpp",
  54. "parse_and_lex_context.cpp",
  55. "parse_and_lex_context.h",
  56. "parser.cpp",
  57. "parser.h",
  58. ],
  59. hdrs = [
  60. "parse.h",
  61. ],
  62. # Disable warnings for generated code.
  63. copts = [
  64. "-Wno-implicit-fallthrough", # Needed to make yyinput() code compile.
  65. "-Wno-unneeded-internal-declaration",
  66. "-Wno-unused-function",
  67. "-Wno-writable-strings",
  68. ],
  69. deps = [
  70. ":bison_wrap",
  71. "//common:check",
  72. "//common:error",
  73. "//common:ostream",
  74. "//common:string_helpers",
  75. "//executable_semantics/ast",
  76. "//executable_semantics/ast:declaration",
  77. "//executable_semantics/ast:expression",
  78. "//executable_semantics/ast:paren_contents",
  79. "//executable_semantics/ast:pattern",
  80. "//executable_semantics/ast:value_category",
  81. "//executable_semantics/common:arena",
  82. "//executable_semantics/common:error_builders",
  83. "//executable_semantics/common:nonnull",
  84. "@llvm-project//llvm:Support",
  85. ],
  86. )
  87. genrule(
  88. name = "syntax_bison_srcs",
  89. srcs = ["parser.ypp"],
  90. outs = [
  91. "parser.cpp",
  92. "parser.h",
  93. "parser.output",
  94. ],
  95. cmd = "M4=$(M4) $(BISON) " +
  96. "--output=$(location parser.cpp) " +
  97. "--report=state " +
  98. "--defines=$(location parser.h) " +
  99. "$(location parser.ypp)",
  100. toolchains = [
  101. "@rules_bison//bison:current_bison_toolchain",
  102. "@rules_m4//m4:current_m4_toolchain",
  103. ],
  104. )
  105. genrule(
  106. name = "syntax_flex_srcs",
  107. srcs = ["lexer.lpp"],
  108. outs = [
  109. "lexer.cpp",
  110. "lexer.h",
  111. ],
  112. cmd = "M4=$(M4) $(FLEX) " +
  113. "--outfile=$(location lexer.cpp) " +
  114. "--header-file=$(location lexer.h) " +
  115. "$(location lexer.lpp)",
  116. toolchains = [
  117. "@rules_flex//flex:current_flex_toolchain",
  118. "@rules_m4//m4:current_m4_toolchain",
  119. ],
  120. )
  121. py_library(
  122. name = "format_grammar_lib",
  123. srcs = ["format_grammar.py"],
  124. )
  125. py_test(
  126. name = "format_grammar_test",
  127. srcs = ["format_grammar_test.py"],
  128. deps = ["format_grammar_lib"],
  129. )
  130. mypy_test(
  131. name = "format_grammar_mypy_test",
  132. include_imports = True,
  133. deps = [":format_grammar_lib"],
  134. )
  135. cc_test(
  136. name = "unimplemented_example_test",
  137. srcs = ["unimplemented_example_test.cpp"],
  138. deps = [
  139. ":parse_test_matchers",
  140. ":syntax",
  141. "//common:gtest_main",
  142. "//executable_semantics/ast:ast_test_matchers",
  143. "@com_google_googletest//:gtest",
  144. ],
  145. )