BUILD 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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("@mypy_integration//:mypy.bzl", "mypy_test")
  5. package(default_visibility = ["//executable_semantics:__pkg__"])
  6. cc_library(
  7. name = "bison_wrap",
  8. hdrs = ["bison_wrap.h"],
  9. deps = ["//common:check"],
  10. )
  11. cc_library(
  12. name = "syntax",
  13. srcs = [
  14. "lexer.cpp",
  15. "lexer.h",
  16. "parse.cpp",
  17. "parse_and_lex_context.cpp",
  18. "parse_and_lex_context.h",
  19. "parser.cpp",
  20. "parser.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",
  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. ],
  44. )
  45. genrule(
  46. name = "syntax_bison_srcs",
  47. srcs = ["parser.ypp"],
  48. outs = [
  49. "parser.cpp",
  50. "parser.h",
  51. "parser.output",
  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 = [
  67. "lexer.cpp",
  68. "lexer.h",
  69. ],
  70. cmd = "M4=$(M4) $(FLEX) " +
  71. "--outfile=$(location lexer.cpp) " +
  72. "--header-file=$(location lexer.h) " +
  73. "$(location lexer.lpp)",
  74. toolchains = [
  75. "@rules_flex//flex:current_flex_toolchain",
  76. "@rules_m4//m4:current_m4_toolchain",
  77. ],
  78. )
  79. py_library(
  80. name = "format_grammar_lib",
  81. srcs = ["format_grammar.py"],
  82. )
  83. py_test(
  84. name = "format_grammar_test",
  85. srcs = ["format_grammar_test.py"],
  86. deps = ["format_grammar_lib"],
  87. )
  88. mypy_test(
  89. name = "format_grammar_mypy_test",
  90. deps = [":format_grammar_lib"],
  91. )