Wed, 19 Dec 2012 03:27:15 +0200
Good bunch of changes
0 | 1 | /* |
2 | * botc source code | |
3 | * Copyright (C) 2012 Santeri `Dusk` Piippo | |
4 | * All rights reserved. | |
5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions are met: | |
8 | * | |
9 | * 1. Redistributions of source code must retain the above copyright notice, | |
10 | * this list of conditions and the following disclaimer. | |
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, | |
12 | * this list of conditions and the following disclaimer in the documentation | |
13 | * and/or other materials provided with the distribution. | |
3 | 14 | * 3. Neither the name of the developer nor the names of its contributors may |
15 | * be used to endorse or promote products derived from this software without | |
16 | * specific prior written permission. | |
0 | 17 | * 4. Redistributions in any form must be accompanied by information on how to |
18 | * obtain complete source code for the software and any accompanying | |
19 | * software that uses the software. The source code must either be included | |
20 | * in the distribution or be available for no more than the cost of | |
21 | * distribution plus a nominal fee, and must be freely redistributable | |
22 | * under reasonable conditions. For an executable file, complete source | |
23 | * code means the source code for all modules it contains. It does not | |
24 | * include source code for modules or files that typically accompany the | |
25 | * major components of the operating system on which the executable file | |
26 | * runs. | |
27 | * | |
28 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
29 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | |
32 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
33 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
34 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
35 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
36 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
37 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
38 | * POSSIBILITY OF SUCH DAMAGE. | |
39 | */ | |
40 | ||
41 | #ifndef __SCRIPTREADER_H__ | |
42 | #define __SCRIPTREADER_H__ | |
43 | ||
44 | #include <stdio.h> | |
45 | #include "str.h" | |
46 | #include "objwriter.h" | |
15
284c2fc6c1cd
Moved command parser to a new function.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
12
diff
changeset
|
47 | #include "commands.h" |
0 | 48 | |
33
fd35f6cb5f28
Added a preprocessor with proper #include support. Macro support via #define is planned too. God, was it a B-I-T-C-H to get working right, though..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
49 | #define MAX_FILESTACK 8 |
59
891b9e6ee139
Added support for continue-statements
Teemu Piippo <crimsondusk64@gmail.com>
parents:
58
diff
changeset
|
50 | #define MAX_SCOPE 32 |
48
976c57f153b3
Added switch support... fixed more problems with marks in the process
Teemu Piippo <crimsondusk64@gmail.com>
parents:
44
diff
changeset
|
51 | #define MAX_CASE 64 |
33
fd35f6cb5f28
Added a preprocessor with proper #include support. Macro support via #define is planned too. God, was it a B-I-T-C-H to get working right, though..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
52 | |
36
a8838b5f1213
Parser can now read expressions 100% properly and can perform variable assignment. I'd call this a milestone!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
35
diff
changeset
|
53 | class ScriptVar; |
a8838b5f1213
Parser can now read expressions 100% properly and can perform variable assignment. I'd call this a milestone!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
35
diff
changeset
|
54 | |
66
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
55 | enum type_e { |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
56 | TYPE_VOID = 0, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
57 | TYPE_INT, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
58 | TYPE_STRING, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
59 | TYPE_FLOAT, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
60 | TYPE_BOOL |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
61 | }; |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
62 | |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
63 | // Operators |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
64 | enum operator_e { |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
65 | OPER_ADD, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
66 | OPER_SUBTRACT, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
67 | OPER_MULTIPLY, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
68 | OPER_DIVIDE, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
69 | OPER_MODULUS, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
70 | OPER_ASSIGN, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
71 | OPER_ASSIGNADD, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
72 | OPER_ASSIGNSUB, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
73 | OPER_ASSIGNMUL, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
74 | OPER_ASSIGNDIV, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
75 | OPER_ASSIGNMOD, // -- 10 |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
76 | OPER_EQUALS, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
77 | OPER_NOTEQUALS, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
78 | OPER_LESSTHAN, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
79 | OPER_GREATERTHAN, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
80 | OPER_LESSTHANEQUALS, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
81 | OPER_GREATERTHANEQUALS, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
82 | OPER_LEFTSHIFT, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
83 | OPER_RIGHTSHIFT, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
84 | OPER_ASSIGNLEFTSHIFT, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
85 | OPER_ASSIGNRIGHTSHIFT, // -- 20 |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
86 | OPER_OR, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
87 | OPER_AND, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
88 | OPER_BITWISEOR, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
89 | OPER_BITWISEAND, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
90 | OPER_BITWISEEOR, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
91 | OPER_TERNARY, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
92 | }; |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
93 | |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
94 | // Mark types |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
95 | enum marktype_e { |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
96 | MARKTYPE_LABEL, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
97 | MARKTYPE_IF, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
98 | MARKTYPE_INTERNAL, // internal structures |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
99 | }; |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
100 | |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
101 | // Block types |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
102 | enum scopetype_e { |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
103 | SCOPETYPE_UNKNOWN, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
104 | SCOPETYPE_IF, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
105 | SCOPETYPE_WHILE, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
106 | SCOPETYPE_FOR, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
107 | SCOPETYPE_DO, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
108 | SCOPETYPE_SWITCH, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
109 | SCOPETYPE_ELSE, |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
110 | }; |
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
111 | |
41
47e686c96d8f
Added while loop support. However, script marks keep getting wrong position numbers..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
112 | // ============================================================================ |
47e686c96d8f
Added while loop support. However, script marks keep getting wrong position numbers..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
113 | // Meta-data about blocks |
59
891b9e6ee139
Added support for continue-statements
Teemu Piippo <crimsondusk64@gmail.com>
parents:
58
diff
changeset
|
114 | struct ScopeInfo { |
41
47e686c96d8f
Added while loop support. However, script marks keep getting wrong position numbers..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
115 | unsigned int mark1; |
47e686c96d8f
Added while loop support. However, script marks keep getting wrong position numbers..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
116 | unsigned int mark2; |
66
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
117 | scopetype_e type; |
43
1b35c9985989
Added for-loop support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
41
diff
changeset
|
118 | DataBuffer* buffer1; |
48
976c57f153b3
Added switch support... fixed more problems with marks in the process
Teemu Piippo <crimsondusk64@gmail.com>
parents:
44
diff
changeset
|
119 | |
976c57f153b3
Added switch support... fixed more problems with marks in the process
Teemu Piippo <crimsondusk64@gmail.com>
parents:
44
diff
changeset
|
120 | // switch-related stuff |
976c57f153b3
Added switch support... fixed more problems with marks in the process
Teemu Piippo <crimsondusk64@gmail.com>
parents:
44
diff
changeset
|
121 | // Which case are we at? |
976c57f153b3
Added switch support... fixed more problems with marks in the process
Teemu Piippo <crimsondusk64@gmail.com>
parents:
44
diff
changeset
|
122 | short casecursor; |
976c57f153b3
Added switch support... fixed more problems with marks in the process
Teemu Piippo <crimsondusk64@gmail.com>
parents:
44
diff
changeset
|
123 | |
976c57f153b3
Added switch support... fixed more problems with marks in the process
Teemu Piippo <crimsondusk64@gmail.com>
parents:
44
diff
changeset
|
124 | // Marks to case-blocks |
976c57f153b3
Added switch support... fixed more problems with marks in the process
Teemu Piippo <crimsondusk64@gmail.com>
parents:
44
diff
changeset
|
125 | int casemarks[MAX_CASE]; |
976c57f153b3
Added switch support... fixed more problems with marks in the process
Teemu Piippo <crimsondusk64@gmail.com>
parents:
44
diff
changeset
|
126 | |
50
2e333a3ca49a
Added default label for switch
Teemu Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
127 | // Numbers of the case labels |
2e333a3ca49a
Added default label for switch
Teemu Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
128 | int casenumbers[MAX_CASE]; |
2e333a3ca49a
Added default label for switch
Teemu Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
129 | |
48
976c57f153b3
Added switch support... fixed more problems with marks in the process
Teemu Piippo <crimsondusk64@gmail.com>
parents:
44
diff
changeset
|
130 | // actual case blocks |
976c57f153b3
Added switch support... fixed more problems with marks in the process
Teemu Piippo <crimsondusk64@gmail.com>
parents:
44
diff
changeset
|
131 | DataBuffer* casebuffers[MAX_CASE]; |
976c57f153b3
Added switch support... fixed more problems with marks in the process
Teemu Piippo <crimsondusk64@gmail.com>
parents:
44
diff
changeset
|
132 | |
976c57f153b3
Added switch support... fixed more problems with marks in the process
Teemu Piippo <crimsondusk64@gmail.com>
parents:
44
diff
changeset
|
133 | // What is the current buffer of the block? |
976c57f153b3
Added switch support... fixed more problems with marks in the process
Teemu Piippo <crimsondusk64@gmail.com>
parents:
44
diff
changeset
|
134 | DataBuffer* recordbuffer; |
41
47e686c96d8f
Added while loop support. However, script marks keep getting wrong position numbers..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
135 | }; |
47e686c96d8f
Added while loop support. However, script marks keep getting wrong position numbers..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
136 | |
47e686c96d8f
Added while loop support. However, script marks keep getting wrong position numbers..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
137 | // ============================================================================ |
47e686c96d8f
Added while loop support. However, script marks keep getting wrong position numbers..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
138 | // The script reader reads the script, parses it and tells the object writer |
47e686c96d8f
Added while loop support. However, script marks keep getting wrong position numbers..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
139 | // the bytecode it needs to write to file. |
0 | 140 | class ScriptReader { |
141 | public: | |
1
f0c61c204bc8
Added support for #include directives, added basic header and statistics printing.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
142 | // ==================================================================== |
f0c61c204bc8
Added support for #include directives, added basic header and statistics printing.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
143 | // MEMBERS |
33
fd35f6cb5f28
Added a preprocessor with proper #include support. Macro support via #define is planned too. God, was it a B-I-T-C-H to get working right, though..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
144 | FILE* fp[MAX_FILESTACK]; |
fd35f6cb5f28
Added a preprocessor with proper #include support. Macro support via #define is planned too. God, was it a B-I-T-C-H to get working right, though..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
145 | char* filepath[MAX_FILESTACK]; |
fd35f6cb5f28
Added a preprocessor with proper #include support. Macro support via #define is planned too. God, was it a B-I-T-C-H to get working right, though..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
146 | int fc; |
fd35f6cb5f28
Added a preprocessor with proper #include support. Macro support via #define is planned too. God, was it a B-I-T-C-H to get working right, though..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
147 | |
fd35f6cb5f28
Added a preprocessor with proper #include support. Macro support via #define is planned too. God, was it a B-I-T-C-H to get working right, though..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
148 | unsigned int pos[MAX_FILESTACK]; |
fd35f6cb5f28
Added a preprocessor with proper #include support. Macro support via #define is planned too. God, was it a B-I-T-C-H to get working right, though..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
149 | unsigned int curline[MAX_FILESTACK]; |
fd35f6cb5f28
Added a preprocessor with proper #include support. Macro support via #define is planned too. God, was it a B-I-T-C-H to get working right, though..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
150 | unsigned int curchar[MAX_FILESTACK]; |
59
891b9e6ee139
Added support for continue-statements
Teemu Piippo <crimsondusk64@gmail.com>
parents:
58
diff
changeset
|
151 | ScopeInfo scopestack[MAX_SCOPE]; |
33
fd35f6cb5f28
Added a preprocessor with proper #include support. Macro support via #define is planned too. God, was it a B-I-T-C-H to get working right, though..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
152 | long savedpos[MAX_FILESTACK]; // filepointer cursor position |
0 | 153 | str token; |
28
fb46d3d40064
Added comment support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
154 | int commentmode; |
34
0a9a5902beaa
Expression parser mostly up and running!! Still work to do on it though.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
155 | long prevpos; |
0a9a5902beaa
Expression parser mostly up and running!! Still work to do on it though.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
156 | str prevtoken; |
0 | 157 | |
1
f0c61c204bc8
Added support for #include directives, added basic header and statistics printing.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
158 | // ==================================================================== |
f0c61c204bc8
Added support for #include directives, added basic header and statistics printing.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
159 | // METHODS |
9
d279af9afd6d
Added proper string checking
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
160 | // scriptreader.cxx: |
7
118d3d5db64f
Improved error handling; added parser warnings
Teemu Piippo <crimsondusk64@gmail.com>
parents:
3
diff
changeset
|
161 | ScriptReader (str path); |
1
f0c61c204bc8
Added support for #include directives, added basic header and statistics printing.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
162 | ~ScriptReader (); |
33
fd35f6cb5f28
Added a preprocessor with proper #include support. Macro support via #define is planned too. God, was it a B-I-T-C-H to get working right, though..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
163 | void OpenFile (str path); |
fd35f6cb5f28
Added a preprocessor with proper #include support. Macro support via #define is planned too. God, was it a B-I-T-C-H to get working right, though..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
164 | void CloseFile (unsigned int u = MAX_FILESTACK); |
0 | 165 | char ReadChar (); |
28
fb46d3d40064
Added comment support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
166 | char PeekChar (int offset = 0); |
33
fd35f6cb5f28
Added a preprocessor with proper #include support. Macro support via #define is planned too. God, was it a B-I-T-C-H to get working right, though..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
167 | bool Next (bool peek = false); |
34
0a9a5902beaa
Expression parser mostly up and running!! Still work to do on it though.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
168 | void Prev (); |
0a9a5902beaa
Expression parser mostly up and running!! Still work to do on it though.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
169 | str PeekNext (int offset = 0); |
0 | 170 | void Seek (unsigned int n, int origin); |
171 | void MustNext (const char* c = ""); | |
34
0a9a5902beaa
Expression parser mostly up and running!! Still work to do on it though.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
172 | void MustThis (const char* c); |
0a9a5902beaa
Expression parser mostly up and running!! Still work to do on it though.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
173 | void MustString (bool gotquote = false); |
35
3d3f6ed40171
Negative literal integers work properly now..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
174 | void MustNumber (bool fromthis = false); |
10
2c0f76090372
Restructured the command def parser, added parameter lists to definition file.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
9
diff
changeset
|
175 | void MustBool (); |
20
d7b13805d1e0
Added string table and support for string parameters in commands.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
176 | bool BoolValue (); |
10
2c0f76090372
Restructured the command def parser, added parameter lists to definition file.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
9
diff
changeset
|
177 | |
7
118d3d5db64f
Improved error handling; added parser warnings
Teemu Piippo <crimsondusk64@gmail.com>
parents:
3
diff
changeset
|
178 | void ParserError (const char* message, ...); |
118d3d5db64f
Improved error handling; added parser warnings
Teemu Piippo <crimsondusk64@gmail.com>
parents:
3
diff
changeset
|
179 | void ParserWarning (const char* message, ...); |
0 | 180 | |
9
d279af9afd6d
Added proper string checking
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
181 | // parser.cxx: |
50
2e333a3ca49a
Added default label for switch
Teemu Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
182 | void ParseBotScript (ObjWriter* w); |
34
0a9a5902beaa
Expression parser mostly up and running!! Still work to do on it though.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
183 | DataBuffer* ParseCommand (CommandDef* comm); |
0a9a5902beaa
Expression parser mostly up and running!! Still work to do on it though.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
184 | DataBuffer* ParseExpression (int reqtype); |
36
a8838b5f1213
Parser can now read expressions 100% properly and can perform variable assignment. I'd call this a milestone!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
35
diff
changeset
|
185 | DataBuffer* ParseAssignment (ScriptVar* var); |
a8838b5f1213
Parser can now read expressions 100% properly and can perform variable assignment. I'd call this a milestone!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
35
diff
changeset
|
186 | int ParseOperator (bool peek = false); |
34
0a9a5902beaa
Expression parser mostly up and running!! Still work to do on it though.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
187 | DataBuffer* ParseExprValue (int reqtype); |
58
bc9317d1b9c9
Renamed 'block stack' to scope stack for more clarified code..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
56
diff
changeset
|
188 | void PushScope (); |
10
2c0f76090372
Restructured the command def parser, added parameter lists to definition file.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
9
diff
changeset
|
189 | |
33
fd35f6cb5f28
Added a preprocessor with proper #include support. Macro support via #define is planned too. God, was it a B-I-T-C-H to get working right, though..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
190 | // preprocessor.cxx: |
fd35f6cb5f28
Added a preprocessor with proper #include support. Macro support via #define is planned too. God, was it a B-I-T-C-H to get working right, though..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
191 | void PreprocessDirectives (); |
fd35f6cb5f28
Added a preprocessor with proper #include support. Macro support via #define is planned too. God, was it a B-I-T-C-H to get working right, though..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
192 | void PreprocessMacros (); |
43
1b35c9985989
Added for-loop support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
41
diff
changeset
|
193 | DataBuffer* ParseStatement (ObjWriter* w); |
50
2e333a3ca49a
Added default label for switch
Teemu Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
194 | void AddSwitchCase (ObjWriter* w, DataBuffer* b); |
33
fd35f6cb5f28
Added a preprocessor with proper #include support. Macro support via #define is planned too. God, was it a B-I-T-C-H to get working right, though..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
195 | |
10
2c0f76090372
Restructured the command def parser, added parameter lists to definition file.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
9
diff
changeset
|
196 | private: |
11
f08abacb46c9
Removed extdelimeters member, said delimeters are always enabled now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
10
diff
changeset
|
197 | bool atnewline; |
10
2c0f76090372
Restructured the command def parser, added parameter lists to definition file.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
9
diff
changeset
|
198 | char c; |
2c0f76090372
Restructured the command def parser, added parameter lists to definition file.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
9
diff
changeset
|
199 | void ParserMessage (const char* header, char* message); |
33
fd35f6cb5f28
Added a preprocessor with proper #include support. Macro support via #define is planned too. God, was it a B-I-T-C-H to get working right, though..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
200 | |
fd35f6cb5f28
Added a preprocessor with proper #include support. Macro support via #define is planned too. God, was it a B-I-T-C-H to get working right, though..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
201 | bool DoDirectivePreprocessing (); |
fd35f6cb5f28
Added a preprocessor with proper #include support. Macro support via #define is planned too. God, was it a B-I-T-C-H to get working right, though..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
202 | char PPReadChar (); |
fd35f6cb5f28
Added a preprocessor with proper #include support. Macro support via #define is planned too. God, was it a B-I-T-C-H to get working right, though..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
203 | void PPMustChar (char c); |
fd35f6cb5f28
Added a preprocessor with proper #include support. Macro support via #define is planned too. God, was it a B-I-T-C-H to get working right, though..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
204 | str PPReadWord (char &term); |
0 | 205 | }; |
206 | ||
66
4fc1ec88aa41
Good bunch of changes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
207 | extern bool g_Neurosphere; |
41
47e686c96d8f
Added while loop support. However, script marks keep getting wrong position numbers..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
208 | |
0 | 209 | #endif // __SCRIPTREADER_H__ |