BUILD 2.3 KB

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