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. ],
  43. )
  44. genrule(
  45. name = "syntax_bison_srcs",
  46. srcs = ["parser.ypp"],
  47. outs = [
  48. "parser.cpp",
  49. "parser.h",
  50. "parser.output",
  51. ],
  52. cmd = "M4=$(M4) $(BISON) " +
  53. "--output=$(location parser.cpp) " +
  54. "--report=state " +
  55. "--defines=$(location parser.h) " +
  56. "$(location parser.ypp)",
  57. toolchains = [
  58. "@rules_bison//bison:current_bison_toolchain",
  59. "@rules_m4//m4:current_m4_toolchain",
  60. ],
  61. )
  62. genrule(
  63. name = "syntax_flex_srcs",
  64. srcs = ["lexer.lpp"],
  65. outs = [
  66. "lexer.cpp",
  67. "lexer.h",
  68. ],
  69. cmd = "M4=$(M4) $(FLEX) " +
  70. "--outfile=$(location lexer.cpp) " +
  71. "--header-file=$(location lexer.h) " +
  72. "$(location lexer.lpp)",
  73. toolchains = [
  74. "@rules_flex//flex:current_flex_toolchain",
  75. "@rules_m4//m4:current_m4_toolchain",
  76. ],
  77. )
  78. py_library(
  79. name = "format_grammar_lib",
  80. srcs = ["format_grammar.py"],
  81. )
  82. py_test(
  83. name = "format_grammar_test",
  84. srcs = ["format_grammar_test.py"],
  85. deps = ["format_grammar_lib"],
  86. )
  87. mypy_test(
  88. name = "format_grammar_mypy_test",
  89. include_imports = True,
  90. deps = [":format_grammar_lib"],
  91. )