BUILD 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. package(default_visibility = ["//executable_semantics:__pkg__"])
  5. cc_library(
  6. name = "bison_wrap",
  7. hdrs = ["bison_wrap.h"],
  8. deps = ["//common:check"],
  9. )
  10. cc_library(
  11. name = "syntax",
  12. srcs = [
  13. "lexer.cpp",
  14. "parse.cpp",
  15. "parse_and_lex_context.cpp",
  16. "parse_and_lex_context.h",
  17. "parser.cpp",
  18. "parser.h",
  19. "syntax_helpers.cpp",
  20. "syntax_helpers.h",
  21. ],
  22. hdrs = [
  23. "parse.h",
  24. ],
  25. # Disable warnings for generated code.
  26. copts = [
  27. "-Wno-unneeded-internal-declaration",
  28. "-Wno-unused-function",
  29. "-Wno-writable-strings",
  30. ],
  31. deps = [
  32. ":bison_wrap",
  33. "//common:check",
  34. "//common:ostream",
  35. "//common:string_helpers",
  36. "//executable_semantics/ast:declaration",
  37. "//executable_semantics/ast:expression",
  38. "//executable_semantics/ast:paren_contents",
  39. "//executable_semantics/common:arena",
  40. "//executable_semantics/common:error",
  41. "//executable_semantics/common:tracing_flag",
  42. "//executable_semantics/interpreter",
  43. "//executable_semantics/interpreter:typecheck",
  44. ],
  45. )
  46. genrule(
  47. name = "syntax_bison_srcs",
  48. srcs = ["parser.ypp"],
  49. outs = [
  50. "parser.cpp",
  51. "parser.h",
  52. ],
  53. cmd = "M4=$(M4) $(BISON) " +
  54. "--output=$(location parser.cpp) " +
  55. "--report=state " +
  56. "--defines=$(location parser.h) " +
  57. "$(location parser.ypp)",
  58. toolchains = [
  59. "@rules_bison//bison:current_bison_toolchain",
  60. "@rules_m4//m4:current_m4_toolchain",
  61. ],
  62. )
  63. genrule(
  64. name = "syntax_flex_srcs",
  65. srcs = ["lexer.lpp"],
  66. outs = ["lexer.cpp"],
  67. cmd = "M4=$(M4) $(FLEX) " +
  68. "--outfile=$(location lexer.cpp) " +
  69. "$(location lexer.lpp)",
  70. toolchains = [
  71. "@rules_flex//flex:current_flex_toolchain",
  72. "@rules_m4//m4:current_m4_toolchain",
  73. ],
  74. )