BUILD 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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-implicit-fallthrough", # Needed to make yyinput() code compile.
  47. "-Wno-unneeded-internal-declaration",
  48. "-Wno-unused-function",
  49. "-Wno-writable-strings",
  50. ],
  51. deps = [
  52. ":bison_wrap",
  53. "//common:check",
  54. "//common:ostream",
  55. "//common:string_helpers",
  56. "//executable_semantics/ast",
  57. "//executable_semantics/ast:declaration",
  58. "//executable_semantics/ast:expression",
  59. "//executable_semantics/ast:paren_contents",
  60. "//executable_semantics/ast:pattern",
  61. "//executable_semantics/common:arena",
  62. "//executable_semantics/common:error",
  63. "//executable_semantics/common:nonnull",
  64. "@llvm-project//llvm:Support",
  65. ],
  66. )
  67. genrule(
  68. name = "syntax_bison_srcs",
  69. srcs = ["parser.ypp"],
  70. outs = [
  71. "parser.cpp",
  72. "parser.h",
  73. "parser.output",
  74. ],
  75. cmd = "M4=$(M4) $(BISON) " +
  76. "--output=$(location parser.cpp) " +
  77. "--report=state " +
  78. "--defines=$(location parser.h) " +
  79. "$(location parser.ypp)",
  80. toolchains = [
  81. "@rules_bison//bison:current_bison_toolchain",
  82. "@rules_m4//m4:current_m4_toolchain",
  83. ],
  84. )
  85. genrule(
  86. name = "syntax_flex_srcs",
  87. srcs = ["lexer.lpp"],
  88. outs = [
  89. "lexer.cpp",
  90. "lexer.h",
  91. ],
  92. cmd = "M4=$(M4) $(FLEX) " +
  93. "--outfile=$(location lexer.cpp) " +
  94. "--header-file=$(location lexer.h) " +
  95. "$(location lexer.lpp)",
  96. toolchains = [
  97. "@rules_flex//flex:current_flex_toolchain",
  98. "@rules_m4//m4:current_m4_toolchain",
  99. ],
  100. )
  101. py_library(
  102. name = "format_grammar_lib",
  103. srcs = ["format_grammar.py"],
  104. )
  105. py_test(
  106. name = "format_grammar_test",
  107. srcs = ["format_grammar_test.py"],
  108. deps = ["format_grammar_lib"],
  109. )
  110. mypy_test(
  111. name = "format_grammar_mypy_test",
  112. include_imports = True,
  113. deps = [":format_grammar_lib"],
  114. )
  115. cc_test(
  116. name = "unimplemented_example_test",
  117. srcs = ["unimplemented_example_test.cpp"],
  118. deps = [
  119. ":parse_test_matchers",
  120. ":syntax",
  121. "//executable_semantics/ast:ast_test_matchers",
  122. "@com_google_googletest//:gtest_main",
  123. ],
  124. )