forked from lcompilers/lpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.h
More file actions
46 lines (35 loc) · 1.14 KB
/
parser.h
File metadata and controls
46 lines (35 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef LPYTHON_PARSER_PARSER_H
#define LPYTHON_PARSER_PARSER_H
#include <libasr/containers.h>
#include <libasr/diagnostics.h>
#include <lpython/parser/tokenizer.h>
namespace LCompilers::LPython {
class Parser
{
public:
std::string inp;
public:
diag::Diagnostics &diag;
Allocator &m_a;
Tokenizer m_tokenizer;
Vec<LPython::AST::stmt_t*> result;
Vec<LPython::AST::type_ignore_t*> type_ignore;
Parser(Allocator &al, diag::Diagnostics &diagnostics)
: diag{diagnostics}, m_a{al} {
result.reserve(al, 32);
type_ignore.reserve(al, 4);
}
void parse(const std::string &input, uint32_t prev_loc);
void handle_yyerror(const Location &loc, const std::string &msg);
};
// Parses Python code to AST
Result<LPython::AST::Module_t*> parse(Allocator &al,
const std::string &s, uint32_t prev_loc,
diag::Diagnostics &diagnostics);
Result<LPython::AST::ast_t*> parse_python_file(Allocator &al,
const std::string &runtime_library_dir,
const std::string &infile,
diag::Diagnostics &diagnostics,
uint32_t prev_loc, bool new_parser);
} // namespace LCompilers::LPython
#endif