BUILD 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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("@rules_cc//cc:defs.bzl", "cc_library")
  5. package(default_visibility = ["//executable_semantics:__subpackages__"])
  6. cc_library(
  7. name = "syntax",
  8. srcs = [
  9. "lexer.cpp",
  10. "parse.cpp",
  11. "parse_and_lex_context.cpp",
  12. "parse_and_lex_context.h",
  13. "parser.cpp",
  14. "parser.h",
  15. "syntax_helpers.cpp",
  16. "syntax_helpers.h",
  17. ],
  18. hdrs = [
  19. "parse.h",
  20. ],
  21. # Disable warnings for generated code.
  22. copts = [
  23. "-Wno-unneeded-internal-declaration",
  24. "-Wno-unused-function",
  25. "-Wno-writable-strings",
  26. ],
  27. deps = [
  28. ":paren_contents",
  29. "//common:check",
  30. "//common:ostream",
  31. "//executable_semantics/ast:declaration",
  32. "//executable_semantics/ast:expression",
  33. "//executable_semantics/common:error",
  34. "//executable_semantics/common:tracing_flag",
  35. "//executable_semantics/interpreter",
  36. "//executable_semantics/interpreter:typecheck",
  37. ],
  38. )
  39. cc_library(
  40. name = "paren_contents",
  41. srcs = ["paren_contents.cpp"],
  42. hdrs = ["paren_contents.h"],
  43. deps = ["//executable_semantics/ast:expression"],
  44. )
  45. cc_test(
  46. name = "paren_contents_test",
  47. srcs = ["paren_contents_test.cpp"],
  48. env = {
  49. # TODO(#580): Remove this when leaks are fixed.
  50. "ASAN_OPTIONS": "detect_leaks=0",
  51. },
  52. deps = [
  53. ":paren_contents",
  54. "@llvm-project//llvm:gtest",
  55. "@llvm-project//llvm:gtest_main",
  56. ],
  57. )
  58. genrule(
  59. name = "syntax_bison_srcs",
  60. srcs = ["parser.ypp"],
  61. outs = [
  62. "parser.cpp",
  63. "parser.h",
  64. ],
  65. cmd = "M4=$(M4) $(BISON) " +
  66. "--output=$(location parser.cpp) " +
  67. "--report=state " +
  68. "--defines=$(location parser.h) " +
  69. "$(location parser.ypp)",
  70. toolchains = [
  71. "@rules_bison//bison:current_bison_toolchain",
  72. "@rules_m4//m4:current_m4_toolchain",
  73. ],
  74. )
  75. genrule(
  76. name = "syntax_flex_srcs",
  77. srcs = ["lexer.lpp"],
  78. outs = ["lexer.cpp"],
  79. cmd = "M4=$(M4) $(FLEX) " +
  80. "--outfile=$(location lexer.cpp) " +
  81. "$(location lexer.lpp)",
  82. toolchains = [
  83. "@rules_flex//flex:current_flex_toolchain",
  84. "@rules_m4//m4:current_m4_toolchain",
  85. ],
  86. )