BUILD 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. "//executable_semantics:tracing_flag",
  30. "//executable_semantics/ast:declaration",
  31. "//executable_semantics/ast:expression",
  32. "//executable_semantics/interpreter",
  33. ],
  34. )
  35. cc_library(
  36. name = "paren_contents",
  37. srcs = ["paren_contents.cpp"],
  38. hdrs = ["paren_contents.h"],
  39. deps = ["//executable_semantics/ast:expression"],
  40. )
  41. cc_test(
  42. name = "paren_contents_test",
  43. srcs = ["paren_contents_test.cpp"],
  44. env = {
  45. # FIXME: Remove this when leaks are fixed.
  46. "ASAN_OPTIONS": "detect_leaks=0",
  47. },
  48. deps = [
  49. ":paren_contents",
  50. "@llvm-project//llvm:gtest",
  51. "@llvm-project//llvm:gtest_main",
  52. ],
  53. )
  54. genrule(
  55. name = "syntax_bison_srcs",
  56. srcs = ["parser.ypp"],
  57. outs = [
  58. "parser.cpp",
  59. "parser.h",
  60. ],
  61. cmd = "M4=$(M4) $(BISON) " +
  62. "--output=$(location parser.cpp) " +
  63. "--defines=$(location parser.h) " +
  64. "$(location parser.ypp)",
  65. toolchains = [
  66. "@rules_bison//bison:current_bison_toolchain",
  67. "@rules_m4//m4:current_m4_toolchain",
  68. ],
  69. )
  70. genrule(
  71. name = "syntax_flex_srcs",
  72. srcs = ["lexer.lpp"],
  73. outs = ["lexer.cpp"],
  74. cmd = "M4=$(M4) $(FLEX) " +
  75. "--outfile=$(location lexer.cpp) " +
  76. "$(location lexer.lpp)",
  77. toolchains = [
  78. "@rules_flex//flex:current_flex_toolchain",
  79. "@rules_m4//m4:current_m4_toolchain",
  80. ],
  81. )