120 {
121 std::vector<Token> tokens;
122 std::string current;
123 bool InQuotes =
FALSE;
124 bool InBracket =
FALSE;
125
126 for (size_t i = 0; i < input.length(); ++i)
127 {
128 char c = input[i];
129
130 if (c == '/')
131 {
132
133
134
135 if (!(tokens.back().second == "script"))
136 {
137 size_t j = i;
138 c = input[++j];
139 if (c == '/')
140 {
141 size_t EndPose = input.find('\n', i);
142 if (EndPose != std::string::npos)
143 {
144
145
146
147 std::string comment(input.substr(i, EndPose - i));
148 i = i + (EndPose - i);
149 if (input[i + 1] == ' ' || input[i + 1] == '\n')
150 {
151 i++;
152 if (input[i + 1] == ' ' || input[i + 1] == '\n')
153 {
154 i++;
155 }
156 }
157 continue;
158 }
159 }
160 else if (c == '*')
161 {
162 size_t EndPose = input.find("*/", i);
163 if (EndPose != std::string::npos)
164 {
165
166 std::string comment(input.substr(i, EndPose - i + 2));
167 i = (i + (EndPose - i)) + 1;
168 if (input[i + 1] == ' ' || input[i + 1] == '\n')
169 {
170 i++;
171 if (input[i + 1] == ' ' || input[i + 1] == '\n')
172 {
173 i++;
174 }
175 }
176 continue;
177 }
178 }
179 }
180 }
181
182 if (InQuotes)
183 {
184 if (c == '"' && input[i - 1] != '\\' && !InBracket)
185 {
186 if (input[i + 1] == ' ' || input[i + 1] == '\n')
187 {
188 i++;
189 if (input[i + 1] == ' ' || input[i + 1] == '\n')
190 {
191 i++;
192 }
193 }
194
197 current.clear();
198 continue;
199 }
200 }
201
202 if (InBracket)
203 {
204 if (c == '}')
205 {
206 if (input[i + 1] == ' ' || input[i + 1] == '\n')
207 {
208 i++;
209 if (input[i + 1] == ' ' || input[i + 1] == '\n')
210 {
211 i++;
212 }
213 }
214
216
218 current.clear();
219 continue;
220 }
221 }
222
223 if (c == ' ' && !InQuotes && !InBracket)
224 {
225 if (!current.empty() && current != " ")
226 {
227 addToken(tokens, current);
228 current.clear();
229 continue;
230 }
231 }
232 else if (c == '"' && input[i - 1] != '\\' && !InBracket)
233 {
235 continue;
236 }
237 else if (c == '{' && !InQuotes && !InBracket)
238 {
240 continue;
241 }
242 current += c;
243 }
244
245 if (!current.empty() && current != " ")
246 {
247 addToken(tokens, current);
248 }
249
250 return tokens;
251 }