-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathword.cpp
More file actions
42 lines (33 loc) · 767 Bytes
/
word.cpp
File metadata and controls
42 lines (33 loc) · 767 Bytes
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
#include "word.h"
Word::Word(std::string lexeme , Tag tag)
:Token(tag)
{
_lexeme = lexeme;
}
Word::~Word()
{
}
std::string Word::toString()
{
return _lexeme;
}
std::string Word::lexeme()
{
return _lexeme;
}
Word* Word::word(Tag tag){
static std::map<Tag,Word *> words;
if(words.size() == 0){
words[AND] = new Word("&&",AND);
words[OR] = new Word("||",OR);
words[EQ] = new Word("==",EQ);
words[NE] = new Word("!=",NE);
words[LE] = new Word("<=",LE);
words[GE] = new Word(">=",GE);
words[MINUS] = new Word("-",MINUS);
words[TRUE] = new Word("true",TRUE);
words[FALSE] = new Word("false",FALSE);
words[TEMP] = new Word("t",TEMP);
}
return words[tag];
}