-
Notifications
You must be signed in to change notification settings - Fork 3
/
token.h
127 lines (92 loc) · 2.05 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#ifndef INCLUDE_TOKEN_H
#define INCLUDE_TOKEN_H
// token.h
// Revision 1-sep-2005
#include "pasmotypes.h"
#include "pasmoimpl.h"
#include <deque>
namespace pasmo {
namespace impl {
typedef int TypeToken;
// Single char operators.
const TypeToken
TypeComma= ',',
TypeColon= ':',
TypePlus= '+',
TypeMinus= '-',
TypeMult= '*',
TypeDiv= '/',
TypeEqOp= '=',
TypeOpen= '(',
TypeClose= ')',
TypeOpenBracket= '[',
TypeCloseBracket= ']',
TypeDollar= '$',
TypeMod= '%',
TypeLtOp= '<',
TypeGtOp= '>',
TypeBitNotOp= '~',
TypeBoolNotOp= '!',
TypeBitAnd= '&',
TypeBitOr= '|',
TypeQuestion= '?',
TypeSharp= '#';
regwCode getregw (TypeToken tt);
regbCode getregb (TypeToken tt);
flagCode getflag86 (flagCode fcode);
flagCode invertflag86 (flagCode fcode);
flagCode getflag (TypeToken tt);
string getflagname (flagCode f);
string gettokenname (TypeToken tt);
class Token {
public:
Token ();
Token (TypeToken ttn);
Token (address n);
Token (address n, const string & sn);
Token (char c);
Token (TypeToken ttn, const string & sn, address style= 0);
TypeToken type () const;
bool isliteral () const;
string raw () const;
string str () const;
address num () const;
string numstr () const;
string literal () const;
string identifier () const;
string macroname () const;
string macroarg () const;
private:
TypeToken tt;
string s;
address number;
};
ostream & operator << (ostream & oss, const Token & tok);
class Tokenizer {
public:
Tokenizer ();
Tokenizer (TypeToken ttok);
Tokenizer (const Tokenizer & tz);
Tokenizer (const string & line, AsmMode asmmode);
~Tokenizer ();
Tokenizer & operator = (const Tokenizer &);
void push_back (const Token & tok);
bool empty () const;
void reset ();
Token getrawtoken ();
Token gettoken ();
Token getmacroarg ();
Token getincludefile ();
void ungettoken ();
friend ostream & operator << (ostream & oss,
const Tokenizer & tz);
class Internal;
private:
Internal * pin;
Internal & in ();
const Internal & in () const;
};
} // namespace impl
} // namespace pasmo
#endif
// End of token.h