scriptreader.h

changeset 68
588cc27e84bb
parent 66
4fc1ec88aa41
equal deleted inserted replaced
67:0a202714eea4 68:588cc27e84bb
41 #ifndef __SCRIPTREADER_H__ 41 #ifndef __SCRIPTREADER_H__
42 #define __SCRIPTREADER_H__ 42 #define __SCRIPTREADER_H__
43 43
44 #include <stdio.h> 44 #include <stdio.h>
45 #include "str.h" 45 #include "str.h"
46 #include "commands.h"
46 #include "objwriter.h" 47 #include "objwriter.h"
47 #include "commands.h"
48 48
49 #define MAX_FILESTACK 8 49 #define MAX_FILESTACK 8
50 #define MAX_SCOPE 32 50 #define MAX_SCOPE 32
51 #define MAX_CASE 64 51 #define MAX_CASE 64
52 52
53 class ScriptVar; 53 class ScriptVar;
54
55 enum type_e {
56 TYPE_VOID = 0,
57 TYPE_INT,
58 TYPE_STRING,
59 TYPE_FLOAT,
60 TYPE_BOOL
61 };
62 54
63 // Operators 55 // Operators
64 enum operator_e { 56 enum operator_e {
65 OPER_ADD, 57 OPER_ADD,
66 OPER_SUBTRACT, 58 OPER_SUBTRACT,
87 OPER_AND, 79 OPER_AND,
88 OPER_BITWISEOR, 80 OPER_BITWISEOR,
89 OPER_BITWISEAND, 81 OPER_BITWISEAND,
90 OPER_BITWISEEOR, 82 OPER_BITWISEEOR,
91 OPER_TERNARY, 83 OPER_TERNARY,
84 OPER_STRLEN,
92 }; 85 };
93 86
94 // Mark types 87 // Mark types
95 enum marktype_e { 88 enum marktype_e {
96 MARKTYPE_LABEL, 89 MARKTYPE_LABEL,
131 DataBuffer* casebuffers[MAX_CASE]; 124 DataBuffer* casebuffers[MAX_CASE];
132 125
133 // What is the current buffer of the block? 126 // What is the current buffer of the block?
134 DataBuffer* recordbuffer; 127 DataBuffer* recordbuffer;
135 }; 128 };
129
130 // ============================================================================
131 typedef struct {
132 str name;
133 type_e type;
134 str val;
135 } constinfo_t;
136 136
137 // ============================================================================ 137 // ============================================================================
138 // The script reader reads the script, parses it and tells the object writer 138 // The script reader reads the script, parses it and tells the object writer
139 // the bytecode it needs to write to file. 139 // the bytecode it needs to write to file.
140 class ScriptReader { 140 class ScriptReader {
179 void ParserWarning (const char* message, ...); 179 void ParserWarning (const char* message, ...);
180 180
181 // parser.cxx: 181 // parser.cxx:
182 void ParseBotScript (ObjWriter* w); 182 void ParseBotScript (ObjWriter* w);
183 DataBuffer* ParseCommand (CommandDef* comm); 183 DataBuffer* ParseCommand (CommandDef* comm);
184 DataBuffer* ParseExpression (int reqtype); 184 DataBuffer* ParseExpression (type_e reqtype);
185 DataBuffer* ParseAssignment (ScriptVar* var); 185 DataBuffer* ParseAssignment (ScriptVar* var);
186 int ParseOperator (bool peek = false); 186 int ParseOperator (bool peek = false);
187 DataBuffer* ParseExprValue (int reqtype); 187 DataBuffer* ParseExprValue (type_e reqtype);
188 str ParseFloat ();
188 void PushScope (); 189 void PushScope ();
189 190
190 // preprocessor.cxx: 191 // preprocessor.cxx:
191 void PreprocessDirectives (); 192 void PreprocessDirectives ();
192 void PreprocessMacros (); 193 void PreprocessMacros ();
202 char PPReadChar (); 203 char PPReadChar ();
203 void PPMustChar (char c); 204 void PPMustChar (char c);
204 str PPReadWord (char &term); 205 str PPReadWord (char &term);
205 }; 206 };
206 207
208 constinfo_t* FindConstant (str token);
207 extern bool g_Neurosphere; 209 extern bool g_Neurosphere;
208 210
209 #endif // __SCRIPTREADER_H__ 211 #endif // __SCRIPTREADER_H__

mercurial