Dynalib Utils
Token.h
Go to the documentation of this file.
1 //
2 // Created by Ken Kopelson on 8/11/17.
3 //
4 
5 #ifndef TOKEN_H
6 #define TOKEN_H
7 
8 #include "../String.h"
9 
10 #define TYPE_INVALID 0x0000
11 #define TOK_TYPE_SPECIAL 0x0001
12 #define TOK_TYPE_OPER 0x0002
13 #define TOK_TYPE_KEYWORD 0x0004
14 #define TOK_TYPE_IDENT 0x0008
15 #define TOK_TYPE_STRING 0x0010
16 #define TOK_TYPE_STRING_LIT 0x0020
17 #define TOK_TYPE_CHAR_LIT 0x0040
18 #define TOK_TYPE_INT_LIT 0x0100
19 #define TOK_TYPE_FLOAT_LIT 0x0200
20 
21 #define TOK_CLASS_ANY 0x0FFF
22 #define TOK_CLASS_NONTERM 0x0007
23 #define TOK_CLASS_TEXT_LIT 0x00F0
24 #define TOK_CLASS_NUMLIT 0x0F00
25 #define TOK_CLASS_LITERAL 0x0FF0
26 #define TOK_CLASS_TERM 0x0FF8
27 
28 #define INVALID_CODE 0
29 #define SPACE_CODE 1
30 #define EOL_CODE 2
31 #define EOS_CODE 3
32 
33 #define BASE_USER_CODE 1000
34 
35 class Token {
36  String _buffer;
37 
38 public:
41  long specialBits = 0L;
42  long double doubleValue = 0.0;
43  bool boolValue = false;
44  time_t timeValue = 0;
45  int lineNumber = 0;
46  int linePosition = 0;
47  int tokenPosition = 0;
48  int intRadix = 10;
49  int fracDigits = 0;
50  long long intPortion = 0;
51  long fracPortion = 0;
52  long expPortion = 0;
53  bool negFound = false;
54  bool intFound = false;
55  bool fracFound = false;
56  bool infNanFound = false;
57  bool expFound = false;
58  bool expSign = false;
59 
60  Token() = default;
61  Token(const Token& token);
62 
63  void copyValues(Token& token);
64  void reset();
65  String& getBuffer();
66  void appendChar(char ch);
67  ulong length();
68 
69  bool isAnySpecial(long bits);
70  bool isAllSpecial(long bits);
71  long setSpecial(long bits);
72  long clearSpecial(long bits);
73 };
74 
75 
76 #endif //TOKEN_H
int code
Definition: Token.h:40
long double doubleValue
Definition: Token.h:42
void appendChar(char ch)
Definition: Token.cpp:45
ulong length()
Definition: Token.cpp:49
int lineNumber
Definition: Token.h:45
int intRadix
Definition: Token.h:48
String & getBuffer()
Definition: Token.cpp:34
bool infNanFound
Definition: Token.h:56
bool isAnySpecial(long bits)
Definition: Token.cpp:53
bool expSign
Definition: Token.h:58
Definition: String.h:60
bool boolValue
Definition: Token.h:43
time_t timeValue
Definition: Token.h:44
long long intPortion
Definition: Token.h:50
bool intFound
Definition: Token.h:54
long clearSpecial(long bits)
Definition: Token.cpp:56
#define TYPE_INVALID
Definition: Token.h:10
long setSpecial(long bits)
Definition: Token.cpp:55
bool expFound
Definition: Token.h:57
bool negFound
Definition: Token.h:53
int linePosition
Definition: Token.h:46
int type
Definition: Token.h:39
int fracDigits
Definition: Token.h:49
Token()=default
bool isAllSpecial(long bits)
Definition: Token.cpp:54
long fracPortion
Definition: Token.h:51
void copyValues(Token &token)
Definition: Token.cpp:11
Definition: Token.h:35
bool fracFound
Definition: Token.h:55
long specialBits
Definition: Token.h:41
void reset()
Definition: Token.cpp:38
int tokenPosition
Definition: Token.h:47
long expPortion
Definition: Token.h:52
#define INVALID_CODE
Definition: Token.h:28