-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalc.cpp
55 lines (40 loc) · 1.01 KB
/
calc.cpp
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
//calc.cpp
//Main file for the calculator app
//Taahir Ahmed
//CSCE 315 Texas A&M University
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
using std::getline;
#include <list>
using std::list;
#include <sstream>
using std::stringstream;
#include <string>
using std::string;
#include "grammarspec.h"
using grammarspec::elements::charset;
using grammarspec::elements::literal;
using grammarspec::results::result;
using grammarspec::results::token;
//TODO make a prefixexpression class, inheriting from element, that performs
//the stack operations in its match function
int main(int argc, char **argv)
{
string user_input;
charset cool_charset("ab");
literal ohai_literal("ohai");
list<result*> *presults;
//Main interaction loop: prompt,read,eval
while(true)
{
cout << "calc>";
getline(cin, user_input);
stringstream line_stream(user_input);
presults = cool_charset.match(line_stream);
cout << "Matched " << presults->size() << " tokens." << endl;
delete presults;
}
return 0;
}