OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/longjump.h" | 5 #include "vm/longjump.h" |
6 #include "vm/object_store.h" | 6 #include "vm/object_store.h" |
7 #include "vm/regexp_parser.h" | 7 #include "vm/regexp_parser.h" |
8 | 8 |
9 namespace dart { | 9 namespace dart { |
10 | 10 |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 has_more_(true), | 209 has_more_(true), |
210 multiline_(multiline), | 210 multiline_(multiline), |
211 simple_(false), | 211 simple_(false), |
212 contains_anchor_(false), | 212 contains_anchor_(false), |
213 is_scanned_for_captures_(false), | 213 is_scanned_for_captures_(false), |
214 failed_(false) { | 214 failed_(false) { |
215 Advance(); | 215 Advance(); |
216 } | 216 } |
217 | 217 |
218 | 218 |
219 bool RegExpParser::ParseFunction(ParsedFunction* parsed_function) { | |
220 VMTagScope tagScope(parsed_function->thread(), | |
221 VMTag::kCompileParseRegExpTagId); | |
222 Zone* zone = parsed_function->zone(); | |
223 RegExp& regexp = RegExp::Handle(parsed_function->function().regexp()); | |
224 | |
225 const String& pattern = String::Handle(regexp.pattern()); | |
226 const bool multiline = regexp.is_multi_line(); | |
227 | |
228 RegExpCompileData* compile_data = new (zone) RegExpCompileData(); | |
229 if (!RegExpParser::ParseRegExp(pattern, multiline, compile_data)) { | |
230 // Parsing failures are handled in the RegExp factory constructor. | |
231 UNREACHABLE(); | |
232 } | |
233 | |
234 regexp.set_num_bracket_expressions(compile_data->capture_count); | |
235 if (compile_data->simple) { | |
236 regexp.set_is_simple(); | |
237 } else { | |
238 regexp.set_is_complex(); | |
239 } | |
240 | |
241 parsed_function->SetRegExpCompileData(compile_data); | |
242 | |
243 return true; | |
244 } | |
245 | |
246 | |
247 uint32_t RegExpParser::Next() { | 219 uint32_t RegExpParser::Next() { |
248 if (has_next()) { | 220 if (has_next()) { |
249 return in().CharAt(next_pos_); | 221 return in().CharAt(next_pos_); |
250 } else { | 222 } else { |
251 return kEndMarker; | 223 return kEndMarker; |
252 } | 224 } |
253 } | 225 } |
254 | 226 |
255 | 227 |
256 void RegExpParser::Advance() { | 228 void RegExpParser::Advance() { |
(...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 String::Handle(String::Concat(result->error, input)); | 1067 String::Handle(String::Concat(result->error, input)); |
1096 const Array& args = Array::Handle(Array::New(1)); | 1068 const Array& args = Array::Handle(Array::New(1)); |
1097 args.SetAt(0, message); | 1069 args.SetAt(0, message); |
1098 | 1070 |
1099 Exceptions::ThrowByType(Exceptions::kFormat, args); | 1071 Exceptions::ThrowByType(Exceptions::kFormat, args); |
1100 } | 1072 } |
1101 return !parser.failed(); | 1073 return !parser.failed(); |
1102 } | 1074 } |
1103 | 1075 |
1104 } // namespace dart | 1076 } // namespace dart |
OLD | NEW |