BUILD 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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/ast:value_category",
  64. "//executable_semantics/common:arena",
  65. "//executable_semantics/common:error",
  66. "//executable_semantics/common:nonnull",
  67. "@llvm-project//llvm:Support",
  68. ],
  69. )
  70. genrule(
  71. name = "syntax_bison_srcs",
  72. srcs = ["parser.ypp"],
  73. outs = [
  74. "parser.cpp",
  75. "parser.h",
  76. "parser.output",
  77. ],
  78. cmd = "M4=$(M4) $(BISON) " +
  79. "--output=$(location parser.cpp) " +
  80. "--report=state " +
  81. "--defines=$(location parser.h) " +
  82. "$(location parser.ypp)",
  83. toolchains = [
  84. "@rules_bison//bison:current_bison_toolchain",
  85. "@rules_m4//m4:current_m4_toolchain",
  86. ],
  87. )
  88. genrule(
  89. name = "syntax_flex_srcs",
  90. srcs = ["lexer.lpp"],
  91. outs = [
  92. "lexer.cpp",
  93. "lexer.h",
  94. ],
  95. cmd = "M4=$(M4) $(FLEX) " +
  96. "--outfile=$(location lexer.cpp) " +
  97. "--header-file=$(location lexer.h) " +
  98. "$(location lexer.lpp)",
  99. toolchains = [
  100. "@rules_flex//flex:current_flex_toolchain",
  101. "@rules_m4//m4:current_m4_toolchain",
  102. ],
  103. )
  104. py_library(
  105. name = "format_grammar_lib",
  106. srcs = ["format_grammar.py"],
  107. )
  108. py_test(
  109. name = "format_grammar_test",
  110. srcs = ["format_grammar_test.py"],
  111. deps = ["format_grammar_lib"],
  112. )
  113. mypy_test(
  114. name = "format_grammar_mypy_test",
  115. include_imports = True,
  116. deps = [":format_grammar_lib"],
  117. )
  118. cc_test(
  119. name = "unimplemented_example_test",
  120. srcs = ["unimplemented_example_test.cpp"],
  121. deps = [
  122. ":parse_test_matchers",
  123. ":syntax",
  124. "//executable_semantics/ast:ast_test_matchers",
  125. "@com_google_googletest//:gtest_main",
  126. ],
  127. )