BUILD 3.1 KB

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