-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_syntax_analyser.cpp
More file actions
59 lines (51 loc) · 1.55 KB
/
test_syntax_analyser.cpp
File metadata and controls
59 lines (51 loc) · 1.55 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
#include <iostream>
#include "FiniteStateMachine.h"
#include "Lexem.h"
#include "syntax_analyser.h"
#include <list>
#include <stack>
using namespace std;
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;";
testQuery = "SELECT Name FROM AdventureWorks2008R2.Production.Product WHERE ListPrice = (SELECT ListPrice FROM AdventureWorks2008R2.Production.Product WHERE Name = 'Chainring Bolts');";
}
cout << "========================================" << endl <<
"1. Starting Lexical Analyze... " << endl <<
"========================================" << endl <<
"Parsing string \'" << testQuery << "\'." << endl;
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;
#ifdef WIN32
system("pause");
#endif // WIN32
return 0;
}