-
Notifications
You must be signed in to change notification settings - Fork 0
/
TerminalExpressions.h
55 lines (48 loc) · 1.28 KB
/
TerminalExpressions.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
#pragma once
#ifndef TERMINALEXPRESSIONS_H_
#define TERMINALEXPRESSIONS_H_
#include "Expression.h"
#include<string>
class Token;
class LiteralExpression:public TerminalExpression
{
public:
class AsciiRange{
public:
friend class LiteralExpression;
AsciiRange(unsigned lowInclusive, unsigned highInclusive):_lowerBound(lowInclusive),_upperBound(highInclusive){}
~AsciiRange(){}
bool IsWithinRange(char x)
{
unsigned numeric_x = (unsigned)x;
if(numeric_x <= _upperBound && numeric_x >= _lowerBound)
return true;
else
return false;
}
private:
AsciiRange(){}
unsigned _lowerBound;
unsigned _upperBound;
};
LiteralExpression(std::string *strng);
LiteralExpression(AsciiRange *ar);
virtual ~LiteralExpression();
virtual void Interpret(Context context);
void InterpretWithString(Context context);
void InterpretWithAsciiRange(Context context);
virtual void AddNode(Token *ast_builder);
private:
AsciiRange *_characterRange;
const char* _terminatingCharacter;
std::string _literalInstance;
};
class ConstLiteralExpression:public TerminalExpression
{
public:
ConstLiteralExpression(std::string *strng):TerminalExpression(strng){}
virtual ~ConstLiteralExpression();
virtual void Interpret(Context context);
virtual void AddNode(Token *ast_builder);
};
#endif