BUILD 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 = [
  6. "//bazel/check_deps:__pkg__",
  7. "//executable_semantics:__pkg__",
  8. ])
  9. cc_library(
  10. name = "bison_wrap",
  11. hdrs = ["bison_wrap.h"],
  12. deps = ["//common:check"],
  13. )
  14. cc_library(
  15. name = "syntax",
  16. srcs = [
  17. "lexer.cpp",
  18. "lexer.h",
  19. "parse.cpp",
  20. "parse_and_lex_context.cpp",
  21. "parse_and_lex_context.h",
  22. "parser.cpp",
  23. "parser.h",
  24. ],
  25. hdrs = [
  26. "parse.h",
  27. ],
  28. # Disable warnings for generated code.
  29. copts = [
  30. "-Wno-unneeded-internal-declaration",
  31. "-Wno-unused-function",
  32. "-Wno-writable-strings",
  33. ],
  34. deps = [
  35. ":bison_wrap",
  36. "//common:check",
  37. "//common:ostream",
  38. "//common:string_helpers",
  39. "//executable_semantics/ast",
  40. "//executable_semantics/ast:declaration",
  41. "//executable_semantics/ast:expression",
  42. "//executable_semantics/ast:paren_contents",
  43. "//executable_semantics/common:arena",
  44. "//executable_semantics/common:error",
  45. ],
  46. )
  47. genrule(
  48. name = "syntax_bison_srcs",
  49. srcs = ["parser.ypp"],
  50. outs = [
  51. "parser.cpp",
  52. "parser.h",
  53. "parser.output",
  54. ],
  55. cmd = "M4=$(M4) $(BISON) " +
  56. "--output=$(location parser.cpp) " +
  57. "--report=state " +
  58. "--defines=$(location parser.h) " +
  59. "$(location parser.ypp)",
  60. toolchains = [
  61. "@rules_bison//bison:current_bison_toolchain",
  62. "@rules_m4//m4:current_m4_toolchain",
  63. ],
  64. )
  65. genrule(
  66. name = "syntax_flex_srcs",
  67. srcs = ["lexer.lpp"],
  68. outs = [
  69. "lexer.cpp",
  70. "lexer.h",
  71. ],
  72. cmd = "M4=$(M4) $(FLEX) " +
  73. "--outfile=$(location lexer.cpp) " +
  74. "--header-file=$(location lexer.h) " +
  75. "$(location lexer.lpp)",
  76. toolchains = [
  77. "@rules_flex//flex:current_flex_toolchain",
  78. "@rules_m4//m4:current_m4_toolchain",
  79. ],
  80. )
  81. py_library(
  82. name = "format_grammar_lib",
  83. srcs = ["format_grammar.py"],
  84. )
  85. py_test(
  86. name = "format_grammar_test",
  87. srcs = ["format_grammar_test.py"],
  88. deps = ["format_grammar_lib"],
  89. )
  90. mypy_test(
  91. name = "format_grammar_mypy_test",
  92. include_imports = True,
  93. deps = [":format_grammar_lib"],
  94. )