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