BUILD 3.2 KB

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