moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / kturtle / src / token.h
blobe91c9a3efe78d336e56113e054a13b6b82be81bc
1 /*
2 Copyright (C) 2003 by Walter Schreppers
3 Copyright (C) 2004 by Cies Breijs
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of version 2 of the GNU General Public
7 License as published by the Free Software Foundation.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #ifndef _TOKEN_H_
21 #define _TOKEN_H_
23 #include <qstring.h>
25 #include "value.h"
28 struct Pos // convenience, it codes a bit nicer with this, i.e.: "int row = tok.start.row"
30 uint row;
31 uint col;
34 struct Token
36 int type; // filled with enumed tokenTypes
37 QString look; // the way the token looks in the text editor
38 Value value; // if the token is a number it can be stored here
39 Pos start; // row'n'col of the starting/ending point of the token
40 Pos end;
44 enum tokenTypes
46 tokNotSet = 0, // inittial type of all tokens
47 tokError = 1, // when there is an error
48 tokUnknown = 2, // when no token was found, a tokUnknown is often a variable, function or error
50 tokIf, // the execution controlling tokens
51 tokElse,
52 tokWhile,
53 tokFor,
54 tokTo,
55 tokStep,
56 tokForEach,
57 tokIn,
58 tokBreak,
59 tokReturn,
61 tokBegin, // the scope delimiting tokens
62 tokEnd,
64 tokNumber, // the containers
65 tokString,
67 tokAssign, // for assignments
69 tokAnd, // and, or, not
70 tokOr,
71 tokNot,
73 tokEq, // ==, !=, >=, >, <=, <
74 tokNe,
75 tokGe,
76 tokGt,
77 tokLe,
78 tokLt,
80 tokBraceOpen, // (, ), +, -, *, /
81 tokBraceClose,
82 tokPlus,
83 tokMinus,
84 tokMul,
85 tokDev,
87 tokComma,
89 tokEOL, // End Of Line token
90 tokEOF, // End Of File token
92 tokLearn, // learn command
94 tokClear, // the 'regular' command tokens
95 tokGo,
96 tokGoX,
97 tokGoY,
98 tokForward,
99 tokBackward,
100 tokDirection,
101 tokTurnLeft,
102 tokTurnRight,
103 tokCenter,
104 tokSetPenWidth,
105 tokPenUp,
106 tokPenDown,
107 tokSetFgColor,
108 tokSetBgColor,
109 tokResizeCanvas,
110 tokSpriteShow,
111 tokSpriteHide,
112 tokSpritePress,
113 tokSpriteChange,
114 tokMessage,
115 tokInputWindow,
116 tokPrint,
117 tokFontType,
118 tokFontSize,
119 tokRepeat,
120 tokRandom,
121 tokWait,
122 tokWrapOn,
123 tokWrapOff,
124 tokReset,
125 tokRun,
127 tokDo // a dummy command
130 // const QString tokenTypeNames[] =
131 // {
132 // /* tokNotSet = 0 */ "",
133 // /* tokError = 1 */ "",
134 // /* tokUnknown = 2 */ "name",
136 // /* tokIf */ "if",
137 // /* tokElse */ "else",
138 // /* tokWhile */ "while",
139 // /* tokFor */ "for",
140 // /* tokTo */ "to",
141 // /* tokStep */ "step",
142 // /* tokForEach */ "each",
143 // /* tokIn */ "in",
144 // /* tokBreak */ "break",
145 // /* tokReturn */ "return",
147 // /* tokBegin */ "",
148 // /* tokEnd */ "",
150 // /* tokNumber */ "number",
151 // /* tokString */ "string",
153 // /* tokAssign */ "asignment",
155 // /* tokAnd */ "and",
156 // /* tokOr */ "or",
157 // /* tokNot */ "not",
159 // /* tokEq */ "questions",
160 // /* tokNe */ "questions",
161 // /* tokGe */ "questions",
162 // /* tokGt */ "questions",
163 // /* tokLe */ "questions",
164 // /* tokLt */ "questions",
166 // /* tokBraceOpen */ "math",
167 // /* tokBraceClose */ "math",
168 // /* tokPlus */ "math",
169 // /* tokMinus */ "math",
170 // /* tokMul */ "math",
171 // /* tokDev */ "math",
173 // /* tokComma */ "",
175 // /* tokEOL */ "",
176 // /* tokEOF */ "",
178 // /* tokLearn */ "learn",
180 // /* tokClear */ "clear",
181 // /* tokGo */ "go",
182 // /* tokGoX */ "gox",
183 // /* tokGoY */ "goy",
184 // /* tokForward */ "forward",
185 // /* tokBackward */ "backward",
186 // /* tokDirection */ "direction",
187 // /* tokTurnLeft */ "turnleft",
188 // /* tokTurnRight */ "turnright",
189 // /* tokCenter */ "center",
190 // /* tokSetPenWidth */ "setpenwidth",
191 // /* tokPenUp */ "penup",
192 // /* tokPenDown */ "pendown",
193 // /* tokSetFgColor */ "setfgcolor",
194 // /* tokSetBgColor */ "setbgcolor",
195 // /* tokResizeCanvas */ "resizecanvas",
196 // /* tokSpriteShow */ "spriteshow",
197 // /* tokSpriteHide */ "spritehide",
198 // /* tokSpritePress */ "",
199 // /* tokSpriteChange */ "",
200 // /* tokMessage */ "message",
201 // /* tokInputWindow */ "inputwindow",
202 // /* tokPrint */ "print",
203 // /* tokFontType */ "",
204 // /* tokFontSize */ "fontsize",
205 // /* tokRepeat */ "repeat",
206 // /* tokRandom */ "random",
207 // /* tokWait */ "wait",
208 // /* tokWrapOn */ "wrapon",
209 // /* tokWrapOff */ "wrapoff",
210 // /* tokReset */ "reset",
211 // /* tokRun */ "run",
213 // /* tokDo */ "",
214 // };
216 // // QString Token::tokenType2name(int tokenType)
217 // // {
218 // // if (tokenType >= 0) return tokenTypeNames[tokenType];
219 // // else return "";
220 // // }
222 #endif // _TOKEN_H_