-
Notifications
You must be signed in to change notification settings - Fork 176
Expand file tree
/
Copy pathparser_exception.h
More file actions
49 lines (36 loc) · 1.12 KB
/
parser_exception.h
File metadata and controls
49 lines (36 loc) · 1.12 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
47
48
49
#ifndef LPYTHON_PARSER_PARSER_EXCEPTION_H
#define LPYTHON_PARSER_PARSER_EXCEPTION_H
#include <libasr/exception.h>
#include <libasr/diagnostics.h>
namespace LCompilers::LPython {
namespace parser_local {
// Local exceptions that are used to terminate the tokenizer.
class TokenizerError
{
public:
diag::Diagnostic d;
public:
TokenizerError(const std::string &msg, const Location &loc)
: d{diag::Diagnostic(msg, diag::Level::Error, diag::Stage::Tokenizer, {
diag::Label("", {loc})
})}
{ }
TokenizerError(const diag::Diagnostic &d) : d{d} { }
};
class ParserError
{
public:
diag::Diagnostic d;
public:
ParserError(const std::string &msg, const Location &loc)
: d{diag::Diagnostic(msg, diag::Level::Error, diag::Stage::Parser, {
diag::Label("", {loc})
})}
{ }
ParserError(const std::string &msg)
: d{diag::Diagnostic(msg, diag::Level::Error, diag::Stage::Parser)}
{ }
};
}
}
#endif // LPYTHON_PARSER_PARSER_EXCEPTION_H