| OLD | NEW |
| 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 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 characters_ = NULL; | 463 characters_ = NULL; |
| 464 atom = new RegExpAtom(char_vector); | 464 atom = new RegExpAtom(char_vector); |
| 465 FlushText(); | 465 FlushText(); |
| 466 } else if (text_.length() > 0) { | 466 } else if (text_.length() > 0) { |
| 467 ASSERT(last_added_ == ADD_ATOM); | 467 ASSERT(last_added_ == ADD_ATOM); |
| 468 atom = text_.RemoveLast(); | 468 atom = text_.RemoveLast(); |
| 469 FlushText(); | 469 FlushText(); |
| 470 } else if (terms_.length() > 0) { | 470 } else if (terms_.length() > 0) { |
| 471 ASSERT(last_added_ == ADD_ATOM); | 471 ASSERT(last_added_ == ADD_ATOM); |
| 472 atom = terms_.RemoveLast(); | 472 atom = terms_.RemoveLast(); |
| 473 if (atom->IsLookahead() || atom->IsAssertion()) { | 473 if (atom->max_match() == 0) { |
| 474 // Guaranteed not to match a non-empty string. | 474 // Guaranteed to only match an empty string. |
| 475 // Assertion as an atom can happen as, e.g., (?:\b) | |
| 476 LAST(ADD_TERM); | 475 LAST(ADD_TERM); |
| 477 if (min == 0) { | 476 if (min == 0) { |
| 478 return; | 477 return; |
| 479 } | 478 } |
| 480 terms_.Add(atom); | 479 terms_.Add(atom); |
| 481 return; | 480 return; |
| 482 } | 481 } |
| 483 } else { | 482 } else { |
| 484 // Only call immediately after adding an atom or character! | 483 // Only call immediately after adding an atom or character! |
| 485 UNREACHABLE(); | 484 UNREACHABLE(); |
| (...skipping 3301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3787 int min; | 3786 int min; |
| 3788 int max; | 3787 int max; |
| 3789 switch (current()) { | 3788 switch (current()) { |
| 3790 // QuantifierPrefix :: | 3789 // QuantifierPrefix :: |
| 3791 // * | 3790 // * |
| 3792 // + | 3791 // + |
| 3793 // ? | 3792 // ? |
| 3794 // { | 3793 // { |
| 3795 case '*': | 3794 case '*': |
| 3796 min = 0; | 3795 min = 0; |
| 3797 max = RegExpQuantifier::kInfinity; | 3796 max = RegExpTree::kInfinity; |
| 3798 Advance(); | 3797 Advance(); |
| 3799 break; | 3798 break; |
| 3800 case '+': | 3799 case '+': |
| 3801 min = 1; | 3800 min = 1; |
| 3802 max = RegExpQuantifier::kInfinity; | 3801 max = RegExpTree::kInfinity; |
| 3803 Advance(); | 3802 Advance(); |
| 3804 break; | 3803 break; |
| 3805 case '?': | 3804 case '?': |
| 3806 min = 0; | 3805 min = 0; |
| 3807 max = 1; | 3806 max = 1; |
| 3808 Advance(); | 3807 Advance(); |
| 3809 break; | 3808 break; |
| 3810 case '{': | 3809 case '{': |
| 3811 if (ParseIntervalQuantifier(&min, &max)) { | 3810 if (ParseIntervalQuantifier(&min, &max)) { |
| 3812 break; | 3811 break; |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3958 min = 10 * min + (current() - '0'); | 3957 min = 10 * min + (current() - '0'); |
| 3959 Advance(); | 3958 Advance(); |
| 3960 } | 3959 } |
| 3961 int max = 0; | 3960 int max = 0; |
| 3962 if (current() == '}') { | 3961 if (current() == '}') { |
| 3963 max = min; | 3962 max = min; |
| 3964 Advance(); | 3963 Advance(); |
| 3965 } else if (current() == ',') { | 3964 } else if (current() == ',') { |
| 3966 Advance(); | 3965 Advance(); |
| 3967 if (current() == '}') { | 3966 if (current() == '}') { |
| 3968 max = RegExpQuantifier::kInfinity; | 3967 max = RegExpTree::kInfinity; |
| 3969 Advance(); | 3968 Advance(); |
| 3970 } else { | 3969 } else { |
| 3971 while (IsDecimalDigit(current())) { | 3970 while (IsDecimalDigit(current())) { |
| 3972 max = 10 * max + (current() - '0'); | 3971 max = 10 * max + (current() - '0'); |
| 3973 Advance(); | 3972 Advance(); |
| 3974 } | 3973 } |
| 3975 if (current() != '}') { | 3974 if (current() != '}') { |
| 3976 Reset(start); | 3975 Reset(start); |
| 3977 return false; | 3976 return false; |
| 3978 } | 3977 } |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4368 start_position, | 4367 start_position, |
| 4369 is_expression); | 4368 is_expression); |
| 4370 return result; | 4369 return result; |
| 4371 } | 4370 } |
| 4372 | 4371 |
| 4373 | 4372 |
| 4374 #undef NEW | 4373 #undef NEW |
| 4375 | 4374 |
| 4376 | 4375 |
| 4377 } } // namespace v8::internal | 4376 } } // namespace v8::internal |
| OLD | NEW |