BUILD 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. "parser.cpp",
  13. "syntax_helpers.cpp",
  14. "syntax_helpers.h",
  15. ],
  16. hdrs = ["parser.h"],
  17. # Disable warnings for generated code.
  18. copts = [
  19. "-Wno-unneeded-internal-declaration",
  20. "-Wno-unused-function",
  21. "-Wno-writable-strings",
  22. ],
  23. deps = [
  24. "//executable_semantics:tracing_flag",
  25. "//executable_semantics/ast:declaration",
  26. "//executable_semantics/ast:expression",
  27. "//executable_semantics/ast:field_list",
  28. "//executable_semantics/interpreter",
  29. ],
  30. )
  31. genrule(
  32. name = "syntax_bison_srcs",
  33. srcs = ["parser.ypp"],
  34. outs = [
  35. "parser.cpp",
  36. "parser.h",
  37. ],
  38. cmd = "M4=$(M4) $(BISON) " +
  39. "--output=$(location parser.cpp) " +
  40. "--defines=$(location parser.h) " +
  41. "$(location parser.ypp)",
  42. toolchains = [
  43. "@rules_bison//bison:current_bison_toolchain",
  44. "@rules_m4//m4:current_m4_toolchain",
  45. ],
  46. )
  47. genrule(
  48. name = "syntax_flex_srcs",
  49. srcs = ["lexer.lpp"],
  50. outs = ["lexer.cpp"],
  51. cmd = "M4=$(M4) $(FLEX) " +
  52. "--outfile=$(location lexer.cpp) " +
  53. "$(location lexer.lpp)",
  54. toolchains = [
  55. "@rules_flex//flex:current_flex_toolchain",
  56. "@rules_m4//m4:current_m4_toolchain",
  57. ],
  58. )