BUILD 3.4 KB

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