xref: /aosp_15_r20/external/pytorch/torch/csrc/jit/frontend/parser.h (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1 #pragma once
2 #include <torch/csrc/Export.h>
3 #include <torch/csrc/jit/frontend/tree.h>
4 #include <torch/csrc/jit/frontend/tree_views.h>
5 #include <memory>
6 
7 namespace torch::jit {
8 
9 struct Decl;
10 struct ParserImpl;
11 struct Lexer;
12 
13 TORCH_API Decl mergeTypesFromTypeComment(
14     const Decl& decl,
15     const Decl& type_annotation_decl,
16     bool is_method);
17 
18 struct TORCH_API Parser {
19   explicit Parser(const std::shared_ptr<Source>& src);
20   TreeRef parseFunction(bool is_method);
21   TreeRef parseClass();
22   Decl parseTypeComment();
23   Expr parseExp();
24   Lexer& lexer();
25   ~Parser();
26 
27  private:
28   std::unique_ptr<ParserImpl> pImpl;
29 };
30 
31 } // namespace torch::jit
32