parse.h 1.0 KB

123456789101112131415161718192021222324252627282930313233
  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. #ifndef CARBON_TOOLCHAIN_PARSE_PARSE_H_
  5. #define CARBON_TOOLCHAIN_PARSE_PARSE_H_
  6. #include "common/ostream.h"
  7. #include "toolchain/diagnostics/diagnostic_emitter.h"
  8. #include "toolchain/lex/tokenized_buffer.h"
  9. #include "toolchain/parse/tree.h"
  10. namespace Carbon::Parse {
  11. struct ParseOptions {
  12. // Options must be set individually, not through initialization.
  13. explicit ParseOptions() = default;
  14. // If set, a consumer for diagnostics. Otherwise, diagnostics go to stderr.
  15. Diagnostics::Consumer* consumer = nullptr;
  16. // If set, enables verbose output.
  17. llvm::raw_ostream* vlog_stream = nullptr;
  18. };
  19. // Parses the token buffer into a `Tree`.
  20. //
  21. // This is the factory function which is used to build parse trees.
  22. auto Parse(Lex::TokenizedBuffer& tokens, ParseOptions options) -> Tree;
  23. } // namespace Carbon::Parse
  24. #endif // CARBON_TOOLCHAIN_PARSE_PARSE_H_