BUILD 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. # TODO(https://github.com/carbon-language/carbon-lang/issues/266):
  5. # Migrate bison/flex usage to a more hermetic bazel build.
  6. load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
  7. package(default_visibility = ["//executable_semantics:__subpackages__"])
  8. cc_library(
  9. name = "syntax",
  10. srcs = [
  11. "lexer.cpp",
  12. "parse.cpp",
  13. "parse_and_lex_context.cpp",
  14. "parse_and_lex_context.h",
  15. "parser.cpp",
  16. "parser.h",
  17. "syntax_helpers.cpp",
  18. "syntax_helpers.h",
  19. ],
  20. hdrs = [
  21. "parse.h",
  22. ],
  23. # Disable warnings for generated code.
  24. copts = [
  25. "-Wno-unneeded-internal-declaration",
  26. "-Wno-unused-function",
  27. "-Wno-writable-strings",
  28. ],
  29. deps = [
  30. "//executable_semantics:tracing_flag",
  31. "//executable_semantics/ast:declaration",
  32. "//executable_semantics/ast:expression",
  33. "//executable_semantics/ast:field_list",
  34. "//executable_semantics/interpreter",
  35. ],
  36. )
  37. genrule(
  38. name = "syntax_bison_srcs",
  39. srcs = ["parser.ypp"],
  40. outs = [
  41. "parser.cpp",
  42. "parser.h",
  43. ],
  44. cmd = "M4=$(M4) $(BISON) " +
  45. "--output=$(location parser.cpp) " +
  46. "--defines=$(location parser.h) " +
  47. "$(location parser.ypp)",
  48. toolchains = [
  49. "@rules_bison//bison:current_bison_toolchain",
  50. "@rules_m4//m4:current_m4_toolchain",
  51. ],
  52. )
  53. genrule(
  54. name = "syntax_flex_srcs",
  55. srcs = ["lexer.lpp"],
  56. outs = ["lexer.cpp"],
  57. cmd = "M4=$(M4) $(FLEX) " +
  58. "--outfile=$(location lexer.cpp) " +
  59. "$(location lexer.lpp)",
  60. toolchains = [
  61. "@rules_flex//flex:current_flex_toolchain",
  62. "@rules_m4//m4:current_m4_toolchain",
  63. ],
  64. )