BUILD 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. "//executable_semantics/common:arena",
  20. "@com_google_googletest//:gtest_main",
  21. ],
  22. )
  23. cc_library(
  24. name = "parse_test_matchers",
  25. testonly = 1,
  26. srcs = ["parse_test_matchers_internal.h"],
  27. hdrs = ["parse_test_matchers.h"],
  28. deps = [
  29. ":syntax",
  30. "@com_google_googletest//:gtest",
  31. "@llvm-project//llvm:Support",
  32. ],
  33. )
  34. cc_library(
  35. name = "syntax",
  36. srcs = [
  37. "lexer.cpp",
  38. "lexer.h",
  39. "parse.cpp",
  40. "parse_and_lex_context.cpp",
  41. "parse_and_lex_context.h",
  42. "parser.cpp",
  43. "parser.h",
  44. ],
  45. hdrs = [
  46. "parse.h",
  47. ],
  48. # Disable warnings for generated code.
  49. copts = [
  50. "-Wno-implicit-fallthrough", # Needed to make yyinput() code compile.
  51. "-Wno-unneeded-internal-declaration",
  52. "-Wno-unused-function",
  53. "-Wno-writable-strings",
  54. ],
  55. deps = [
  56. ":bison_wrap",
  57. "//common:check",
  58. "//common:error",
  59. "//common:ostream",
  60. "//common:string_helpers",
  61. "//executable_semantics/ast",
  62. "//executable_semantics/ast:declaration",
  63. "//executable_semantics/ast:expression",
  64. "//executable_semantics/ast:paren_contents",
  65. "//executable_semantics/ast:pattern",
  66. "//executable_semantics/ast:value_category",
  67. "//executable_semantics/common:arena",
  68. "//executable_semantics/common:error",
  69. "//executable_semantics/common:nonnull",
  70. "@llvm-project//llvm:Support",
  71. ],
  72. )
  73. genrule(
  74. name = "syntax_bison_srcs",
  75. srcs = ["parser.ypp"],
  76. outs = [
  77. "parser.cpp",
  78. "parser.h",
  79. "parser.output",
  80. ],
  81. cmd = "M4=$(M4) $(BISON) " +
  82. "--output=$(location parser.cpp) " +
  83. "--report=state " +
  84. "--defines=$(location parser.h) " +
  85. "$(location parser.ypp)",
  86. toolchains = [
  87. "@rules_bison//bison:current_bison_toolchain",
  88. "@rules_m4//m4:current_m4_toolchain",
  89. ],
  90. )
  91. genrule(
  92. name = "syntax_flex_srcs",
  93. srcs = ["lexer.lpp"],
  94. outs = [
  95. "lexer.cpp",
  96. "lexer.h",
  97. ],
  98. cmd = "M4=$(M4) $(FLEX) " +
  99. "--outfile=$(location lexer.cpp) " +
  100. "--header-file=$(location lexer.h) " +
  101. "$(location lexer.lpp)",
  102. toolchains = [
  103. "@rules_flex//flex:current_flex_toolchain",
  104. "@rules_m4//m4:current_m4_toolchain",
  105. ],
  106. )
  107. py_library(
  108. name = "format_grammar_lib",
  109. srcs = ["format_grammar.py"],
  110. )
  111. py_test(
  112. name = "format_grammar_test",
  113. srcs = ["format_grammar_test.py"],
  114. deps = ["format_grammar_lib"],
  115. )
  116. mypy_test(
  117. name = "format_grammar_mypy_test",
  118. include_imports = True,
  119. deps = [":format_grammar_lib"],
  120. )
  121. cc_test(
  122. name = "unimplemented_example_test",
  123. srcs = ["unimplemented_example_test.cpp"],
  124. deps = [
  125. ":parse_test_matchers",
  126. ":syntax",
  127. "//executable_semantics/ast:ast_test_matchers",
  128. "@com_google_googletest//:gtest_main",
  129. ],
  130. )