Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1126)

Side by Side Diff: src/parser.cc

Issue 9638: More automaton translation (Closed)
Patch Set: Created 12 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 // on the input stream. After pushing it back, it becomes the character 458 // on the input stream. After pushing it back, it becomes the character
459 // returned by current(). There is a limited amount of push-back buffer. 459 // returned by current(). There is a limited amount of push-back buffer.
460 // A function using PushBack should check that it doesn't push back more 460 // A function using PushBack should check that it doesn't push back more
461 // than kMaxPushback characters, and it should not push back more characters 461 // than kMaxPushback characters, and it should not push back more characters
462 // than it has read. 462 // than it has read.
463 void PushBack(uc32 character); 463 void PushBack(uc32 character);
464 bool CanPushBack(); 464 bool CanPushBack();
465 465
466 bool HasCharacterEscapes(); 466 bool HasCharacterEscapes();
467 467
468 int captures_started() { return captures_started_; }
469
468 static const uc32 kEndMarker = unibrow::Utf8::kBadChar; 470 static const uc32 kEndMarker = unibrow::Utf8::kBadChar;
469 private: 471 private:
470 uc32 current() { return current_; } 472 uc32 current() { return current_; }
471 uc32 next() { return next_; } 473 uc32 next() { return next_; }
472 bool has_more() { return has_more_; } 474 bool has_more() { return has_more_; }
473 bool has_next() { return has_next_; } 475 bool has_next() { return has_next_; }
474 unibrow::CharacterStream* in() { return in_; } 476 unibrow::CharacterStream* in() { return in_; }
475 uc32 current_; 477 uc32 current_;
476 uc32 next_; 478 uc32 next_;
477 bool has_more_; 479 bool has_more_;
(...skipping 3661 matching lines...) Expand 10 before | Expand all | Expand 10 after
4139 PreParser parser(no_script, allow_natives_syntax, extension); 4141 PreParser parser(no_script, allow_natives_syntax, extension);
4140 if (!parser.PreParseProgram(stream)) return NULL; 4142 if (!parser.PreParseProgram(stream)) return NULL;
4141 // The list owns the backing store so we need to clone the vector. 4143 // The list owns the backing store so we need to clone the vector.
4142 // That way, the result will be exactly the right size rather than 4144 // That way, the result will be exactly the right size rather than
4143 // the expected 50% too large. 4145 // the expected 50% too large.
4144 Vector<unsigned> store = parser.recorder()->store()->ToVector().Clone(); 4146 Vector<unsigned> store = parser.recorder()->store()->ToVector().Clone();
4145 return new ScriptDataImpl(store); 4147 return new ScriptDataImpl(store);
4146 } 4148 }
4147 4149
4148 4150
4149 RegExpTree* ParseRegExp(unibrow::CharacterStream* stream, 4151 bool ParseRegExp(unibrow::CharacterStream* stream, RegExpParseResult* result) {
4150 Handle<String>* error, 4152 ASSERT(result != NULL);
4151 bool* has_character_escapes) { 4153 // Get multiline flag somehow
4152 ASSERT(error->is_null()); 4154 RegExpParser parser(stream, &result->error, false);
4153 RegExpParser parser(stream, error, false); // Get multiline flag somehow
4154 bool ok = true; 4155 bool ok = true;
4155 RegExpTree* result = parser.ParsePattern(&ok); 4156 result->tree = parser.ParsePattern(&ok);
4156 if (!ok) { 4157 if (!ok) {
4157 ASSERT(result == NULL); 4158 ASSERT(result->tree == NULL);
4158 ASSERT(!error->is_null()); 4159 ASSERT(!result->error.is_null());
4159 } else { 4160 } else {
4160 ASSERT(result != NULL); 4161 ASSERT(result->tree != NULL);
4161 ASSERT(error->is_null()); 4162 ASSERT(result->error.is_null());
4162 } 4163 }
4163 if (ok && has_character_escapes != NULL) { 4164 if (ok) {
4164 *has_character_escapes = parser.HasCharacterEscapes(); 4165 result->has_character_escapes = parser.HasCharacterEscapes();
4166 result->capture_count = parser.captures_started();
4165 } 4167 }
4166 return result; 4168 return ok;
4167 } 4169 }
4168 4170
4169 4171
4170 FunctionLiteral* MakeAST(bool compile_in_global_context, 4172 FunctionLiteral* MakeAST(bool compile_in_global_context,
4171 Handle<Script> script, 4173 Handle<Script> script,
4172 v8::Extension* extension, 4174 v8::Extension* extension,
4173 ScriptDataImpl* pre_data) { 4175 ScriptDataImpl* pre_data) {
4174 bool allow_natives_syntax = 4176 bool allow_natives_syntax =
4175 always_allow_natives_syntax || 4177 always_allow_natives_syntax ||
4176 FLAG_allow_natives_syntax || 4178 FLAG_allow_natives_syntax ||
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
4212 start_position, 4214 start_position,
4213 is_expression); 4215 is_expression);
4214 return result; 4216 return result;
4215 } 4217 }
4216 4218
4217 4219
4218 #undef NEW 4220 #undef NEW
4219 4221
4220 4222
4221 } } // namespace v8::internal 4223 } } // namespace v8::internal
OLDNEW
« src/jsregexp.cc ('K') | « src/parser.h ('k') | test/cctest/test-regexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698