-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.cpp
More file actions
65 lines (61 loc) · 1.27 KB
/
Copy pathparser.cpp
File metadata and controls
65 lines (61 loc) · 1.27 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <iostream>
#include <string>
#include "parser.h"
#include "parser_node.h"
#include "parser_token.h"
#include "parser_lexer.h"
#include "parser_syntaxtree.h"
#include "parser_interp.h"
#include "rm_error.h"
#include "pf_error.h"
#include "ix_error.h"
#include "ql_error.h"
#include "sm_error.h"
using namespace std;
static NODE* parse_tree;
extern PFManager pfManager;
extern SMManager smManager;
extern QLManager qlManager;
bool stop = false;
void PrintError(RC rc)
{
if (abs(rc) <= END_PF_WARN)
PFPrintError(rc);
else if (abs(rc) <= END_RM_WARN)
RMPrintError(rc);
else if (abs(rc) <= END_IX_WARN)
IXPrintError(rc);
else if (abs(rc) <= END_SM_WARN)
SMPrintError(rc);
else if (abs(rc) <= END_QL_WARN)
QLPrintError(rc);
else
cerr << "Error code out of range: " << rc << "\n";
}
RC RBparse()
{
RC errval;
stop = false;
string buffer;
LexerPtr lexer = Lexer::instance();
SyntaxTree tree(lexer);
while (!stop) {
cout << PROMPT;
cout.flush();
getline(cin, buffer);
tree.resetParser(buffer);
try {
parse_tree = tree.buildSyntaxTree();
}
catch (const GeneralError& err)
{
cerr << err.what() << endl;
continue;
}
if (errval = interp(parse_tree)) { /* ½âÎöÓï·¨Ê÷ */
PrintError(errval);
if (errval < 0) stop = true;
}
}
return 0;
}