BUILD 2.2 KB

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