BUILD 2.4 KB

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