|
1 /* |
|
2 Copyright 2012-2014 Santeri Piippo |
|
3 All rights reserved. |
|
4 |
|
5 Redistribution and use in source and binary forms, with or without |
|
6 modification, are permitted provided that the following conditions |
|
7 are met: |
|
8 |
|
9 1. Redistributions of source code must retain the above copyright |
|
10 notice, this list of conditions and the following disclaimer. |
|
11 2. Redistributions in binary form must reproduce the above copyright |
|
12 notice, this list of conditions and the following disclaimer in the |
|
13 documentation and/or other materials provided with the distribution. |
|
14 3. The name of the author may not be used to endorse or promote products |
|
15 derived from this software without specific prior written permission. |
|
16 |
|
17 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
|
18 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
|
19 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
|
20 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
|
21 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
|
22 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
23 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
24 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
|
26 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
27 */ |
|
28 |
|
29 #ifndef TOKENS_H |
|
30 #define TOKENS_H |
|
31 |
|
32 #include <climits> |
|
33 #include "macros.h" |
|
34 |
|
35 // ======================================================= |
|
36 named_enum ETokenType |
|
37 { |
|
38 // Non-word tokens |
|
39 TK_LeftShiftAssign, |
|
40 TK_RightShiftAssign, |
|
41 TK_Equals, |
|
42 TK_NotEquals, |
|
43 TK_AddAssign, |
|
44 TK_SubAssign, |
|
45 TK_MultiplyAssign, |
|
46 TK_DivideAssign, |
|
47 TK_ModulusAssign, |
|
48 TK_LeftShift, |
|
49 TK_RightShift, |
|
50 TK_AtLeast, |
|
51 TK_AtMost, |
|
52 TK_DoubleAmperstand, |
|
53 TK_DoubleBar, |
|
54 TK_DoublePlus, |
|
55 TK_DoubleMinus, |
|
56 TK_SingleQuote, |
|
57 TK_DollarSign, |
|
58 TK_ParenStart, |
|
59 TK_ParenEnd, |
|
60 TK_BracketStart, |
|
61 TK_BracketEnd, |
|
62 TK_BraceStart, |
|
63 TK_BraceEnd, |
|
64 TK_Assign, |
|
65 TK_Plus, |
|
66 TK_Minus, |
|
67 TK_Multiply, |
|
68 TK_Divide, |
|
69 TK_Modulus, |
|
70 TK_Comma, |
|
71 TK_Lesser, |
|
72 TK_Greater, |
|
73 TK_Dot, |
|
74 TK_Colon, |
|
75 TK_Semicolon, |
|
76 TK_Hash, |
|
77 TK_ExclamationMark, |
|
78 TK_Amperstand, |
|
79 TK_Bar, |
|
80 TK_Caret, |
|
81 TK_QuestionMark, |
|
82 TK_Arrow, |
|
83 |
|
84 // -------------- |
|
85 // Named tokens |
|
86 TK_Bool, |
|
87 TK_Break, |
|
88 TK_Case, |
|
89 TK_Continue, |
|
90 TK_Const, |
|
91 TK_Constexpr, |
|
92 TK_Default, |
|
93 TK_Do, |
|
94 TK_Else, |
|
95 TK_Event, |
|
96 TK_Eventdef, |
|
97 TK_For, |
|
98 TK_Funcdef, |
|
99 TK_If, |
|
100 TK_Int, |
|
101 TK_Mainloop, |
|
102 TK_Onenter, |
|
103 TK_Onexit, |
|
104 TK_State, |
|
105 TK_Switch, |
|
106 TK_Str, |
|
107 TK_Using, |
|
108 TK_Var, |
|
109 TK_Void, |
|
110 TK_While, |
|
111 TK_True, |
|
112 TK_False, |
|
113 |
|
114 // These ones aren't implemented yet but I plan to do so, thus they are |
|
115 // reserved. Also serves as a to-do list of sorts for me. >:F |
|
116 TK_Enum, |
|
117 TK_Func, |
|
118 TK_Return, |
|
119 |
|
120 // -------------- |
|
121 // Generic tokens |
|
122 TK_Symbol, |
|
123 TK_Number, |
|
124 TK_String, |
|
125 TK_Any, |
|
126 }; |
|
127 |
|
128 static const int gFirstNamedToken = TK_Bool; |
|
129 static const int gLastNamedToken = (int) TK_Symbol - 1; |
|
130 |
|
131 #endif |