-
Notifications
You must be signed in to change notification settings - Fork 0
/
Token.h
58 lines (42 loc) · 1.14 KB
/
Token.h
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
#pragma once
#ifndef TOKEN_H_
#define TOKEN_H_
#include <cstdlib>
#include <typeinfo>
#include<string>
#include<cstring>
#include "Expression.h"
#include "FunctionTree.h"
class Context;
class Expression;
class NonTerminalExpression;
class Token:public Expression
{
public:
Token(void);
virtual ~Token(void);
FunctionTree<std::string>* GetAbstractSyntaxTree(Context context);
void SetExpression(Expression *expression);
void AddLeaf(std::string);
void AddInternalNode(std::string operation);
virtual void Interpret(Context context);
protected:
Expression *_expression;
FunctionTree<std::string> *_ast;
};
class Keyword:public Token
{
public:
Keyword(std::string *key);
virtual ~Keyword();
std::string* GetKeyword(){return _keyword;}
friend bool operator<(Keyword const& lhs, Keyword const& rhs);
friend bool operator==(Keyword const& lhs, Keyword const& rhs);
friend bool operator>(Keyword const& lhs, Keyword const& rhs);
operator const std::string*(){return _keyword;}
virtual void Interpret(Context context);
friend bool operator< (Keyword const& lhs, std::string* const& rhs);
private:
std::string *_keyword;
};
#endif