92 } |
91 } |
93 |
92 |
94 // true if was found, false if not. |
93 // true if was found, false if not. |
95 bool ScriptReader::Next () { |
94 bool ScriptReader::Next () { |
96 str tmp = ""; |
95 str tmp = ""; |
97 bool dontreadnext = false; |
|
98 while (!feof (fp)) { |
96 while (!feof (fp)) { |
99 c = ReadChar (); |
97 c = ReadChar (); |
100 |
98 |
101 // Extended delimeters: basically any non-alnum characters. |
99 // Non-alphanumber characters (sans underscore) break the word too. |
102 // These delimeters break the word too. If there was prior data, |
100 // If there was prior data, the delimeter pushes the cursor back so |
103 // the delimeter pushes the cursor back so that the next character |
101 // that the next character will be the same delimeter. If there isn't, |
104 // will be the same delimeter. If there isn't, the delimeter itself |
102 // the delimeter itself is included (and thus becomes a token itself.) |
105 // is included (and thus becomes a token itself.) |
103 if ((c >= 33 && c <= 47) || |
106 bool shouldBreak = false; |
104 (c >= 58 && c <= 64) || |
107 if (extdelimeters) { |
105 (c >= 91 && c <= 96 && c != '_') || |
108 if ((c >= 33 && c <= 47) || |
106 (c >= 123 && c <= 126)) { |
109 (c >= 58 && c <= 64) || |
107 if (tmp.len()) |
110 // underscore isn't a delimeter |
108 fseek (fp, ftell (fp) - 1, SEEK_SET); |
111 (c >= 91 && c <= 96 && c != 95) || |
109 else |
112 (c >= 123 && c <= 126)) { |
110 tmp += c; |
113 if (tmp.len()) |
111 break; |
114 fseek (fp, ftell (fp) - 1, SEEK_SET); |
|
115 else |
|
116 tmp += c; |
|
117 shouldBreak = true; |
|
118 break; |
|
119 } |
|
120 } |
112 } |
121 if (shouldBreak) |
|
122 break; |
|
123 |
113 |
124 if (IsDelimeter (c)) { |
114 if (IsDelimeter (c)) { |
125 // Don't break if we haven't gathered anything yet. |
115 // Don't break if we haven't gathered anything yet. |
126 if (tmp.len()) |
116 if (tmp.len()) |
127 break; |
117 break; |
205 header, filepath.chars(), curline, curchar, message); |
195 header, filepath.chars(), curline, curchar, message); |
206 } |
196 } |
207 |
197 |
208 // I guess this should be a void function putting the return value into token? |
198 // I guess this should be a void function putting the return value into token? |
209 str ScriptReader::MustGetString () { |
199 str ScriptReader::MustGetString () { |
210 if (!extdelimeters) |
|
211 ParserError ("MustGetString doesn't work with parsers not using extended delimeters!"); |
|
212 |
|
213 MustNext ("\""); |
200 MustNext ("\""); |
214 |
201 |
215 str string; |
202 str string; |
216 // Keep reading characters until we find a terminating quote. |
203 // Keep reading characters until we find a terminating quote. |
217 while (1) { |
204 while (1) { |