forked from movchan74/LightDBMS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_syntax_analyser.cpp
More file actions
57 lines (48 loc) · 1.39 KB
/
test_syntax_analyser.cpp
File metadata and controls
57 lines (48 loc) · 1.39 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
#include <iostream>
#include "Events.h"
#include <iostream>
#include "FiniteStateMachine.h"
#include "lexem.h"
#include "syntax_analyser.h"
#include <list>
#include <stack>
using namespace std;
using namespace Lexem;
int main(int argc, char *argv[])
{
string testQuery;
if (argc > 1) {
testQuery = argv[1];
} else {
testQuery = "select name, price from items where a*b=c#;";
}
cout << "========================================" << endl <<
"1. Starting Lexical Analyze... " << endl <<
"========================================" << endl <<
"Parsing string \'" << testQuery << "\'." << endl;
Machine::FiniteStateMachine machine;
machine.Process(testQuery);
for(std::list<Lexem::Lexem>::iterator it = machine.lexems.begin(); it != machine.lexems.end(); ++it)
{
std::cout << it->getType() << " " << it->getValue() << std::endl;
}
cout << "========================================" << endl <<
"2. Starting Syntax Analyze... " << endl <<
"========================================" << endl;
SyntaxAnalyser analyser;
bool success = analyser.analyse(machine.lexems);
if (success)
cout << "Success!" << endl;
else
cout << "Error!" << endl;
// stack<int> s;
// s.push(10);
// s.push(30);
// while (!s.empty()) {
// cout << s.top() << endl;
// s.pop();
// }
// cout << (int)l2.getType() << endl;
// cout << l2.getValue() << endl;
return 0;
}