-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGMLCinParser.cpp
More file actions
59 lines (41 loc) · 1.41 KB
/
Copy pathGMLCinParser.cpp
File metadata and controls
59 lines (41 loc) · 1.41 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
//----------------------------------------------------------------------
/// \author Markus Krallinger 0630748, Group: 20
/// \brief Reads an input from stdin an creates the corresponding tokens
/// Last Changes: 22.06.2008
//----------------------------------------------------------------------
#include "GMLCinParser.h"
#include <string>
#include <iostream>
#include <vector>
#include <map>
#include <sstream>
#include <math.h>
#include <exception>
#include <stdexcept>
#include "TokenTypes.h"
#include <iostream>
using std::string;
using std::getline;
//----------------------------------------------------------------------
GMLCinParser::GMLCinParser(std::istream &input) : stream(input)
{}
//----------------------------------------------------------------------
// /// \parse the input and returns a token
GMLToken GMLCinParser::parse()
{
for (string line; std::getline(stream, line); ) {
size_t pos = line.find("%");
if(pos != string::npos)
line = line.substr(0, pos);
std::stringstream program(line);
string single_token;
while (program >> single_token)
{
m_program.push_back(getTokenFromString(single_token));
}
}
GMLToken token;
token.m_type = FUNCTION;
token.m_int[0] = 0;
return token;
}