BUILD 2.6 KB

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