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 3913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3924 break; | 3924 break; |
3925 } | 3925 } |
3926 case '|': { | 3926 case '|': { |
3927 Advance(); | 3927 Advance(); |
3928 builder->NewAlternative(); | 3928 builder->NewAlternative(); |
3929 continue; | 3929 continue; |
3930 } | 3930 } |
3931 case '*': | 3931 case '*': |
3932 case '+': | 3932 case '+': |
3933 case '?': | 3933 case '?': |
3934 ReportError(CStrVector("Nothing to repeat") CHECK_FAILED); | 3934 return ReportError(CStrVector("Nothing to repeat")); |
3935 case '^': { | 3935 case '^': { |
3936 Advance(); | 3936 Advance(); |
3937 if (multiline_) { | 3937 if (multiline_) { |
3938 builder->AddAssertion( | 3938 builder->AddAssertion( |
3939 new RegExpAssertion(RegExpAssertion::START_OF_LINE)); | 3939 new RegExpAssertion(RegExpAssertion::START_OF_LINE)); |
3940 } else { | 3940 } else { |
3941 builder->AddAssertion( | 3941 builder->AddAssertion( |
3942 new RegExpAssertion(RegExpAssertion::START_OF_INPUT)); | 3942 new RegExpAssertion(RegExpAssertion::START_OF_INPUT)); |
3943 set_contains_anchor(); | 3943 set_contains_anchor(); |
3944 } | 3944 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3999 case '[': { | 3999 case '[': { |
4000 RegExpTree* atom = ParseCharacterClass(CHECK_FAILED); | 4000 RegExpTree* atom = ParseCharacterClass(CHECK_FAILED); |
4001 builder->AddAtom(atom); | 4001 builder->AddAtom(atom); |
4002 break; | 4002 break; |
4003 } | 4003 } |
4004 // Atom :: | 4004 // Atom :: |
4005 // \ AtomEscape | 4005 // \ AtomEscape |
4006 case '\\': | 4006 case '\\': |
4007 switch (Next()) { | 4007 switch (Next()) { |
4008 case kEndMarker: | 4008 case kEndMarker: |
4009 ReportError(CStrVector("\\ at end of pattern") CHECK_FAILED); | 4009 return ReportError(CStrVector("\\ at end of pattern")); |
4010 case 'b': | 4010 case 'b': |
4011 Advance(2); | 4011 Advance(2); |
4012 builder->AddAssertion( | 4012 builder->AddAssertion( |
4013 new RegExpAssertion(RegExpAssertion::BOUNDARY)); | 4013 new RegExpAssertion(RegExpAssertion::BOUNDARY)); |
4014 continue; | 4014 continue; |
4015 case 'B': | 4015 case 'B': |
4016 Advance(2); | 4016 Advance(2); |
4017 builder->AddAssertion( | 4017 builder->AddAssertion( |
4018 new RegExpAssertion(RegExpAssertion::NON_BOUNDARY)); | 4018 new RegExpAssertion(RegExpAssertion::NON_BOUNDARY)); |
4019 continue; | 4019 continue; |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4486 ASSERT_EQ(0, *char_class); | 4486 ASSERT_EQ(0, *char_class); |
4487 uc32 first = current(); | 4487 uc32 first = current(); |
4488 if (first == '\\') { | 4488 if (first == '\\') { |
4489 switch (Next()) { | 4489 switch (Next()) { |
4490 case 'w': case 'W': case 'd': case 'D': case 's': case 'S': { | 4490 case 'w': case 'W': case 'd': case 'D': case 's': case 'S': { |
4491 *char_class = Next(); | 4491 *char_class = Next(); |
4492 Advance(2); | 4492 Advance(2); |
4493 return CharacterRange::Singleton(0); // Return dummy value. | 4493 return CharacterRange::Singleton(0); // Return dummy value. |
4494 } | 4494 } |
4495 case kEndMarker: | 4495 case kEndMarker: |
4496 ReportError(CStrVector("\\ at end of pattern") CHECK_FAILED); | 4496 return ReportError(CStrVector("\\ at end of pattern")); |
4497 default: | 4497 default: |
4498 uc32 c = ParseClassCharacterEscape(CHECK_FAILED); | 4498 uc32 c = ParseClassCharacterEscape(CHECK_FAILED); |
4499 return CharacterRange::Singleton(c); | 4499 return CharacterRange::Singleton(c); |
4500 } | 4500 } |
4501 } else { | 4501 } else { |
4502 Advance(); | 4502 Advance(); |
4503 return CharacterRange::Singleton(first); | 4503 return CharacterRange::Singleton(first); |
4504 } | 4504 } |
4505 } | 4505 } |
4506 | 4506 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4679 start_position, | 4679 start_position, |
4680 is_expression); | 4680 is_expression); |
4681 return result; | 4681 return result; |
4682 } | 4682 } |
4683 | 4683 |
4684 | 4684 |
4685 #undef NEW | 4685 #undef NEW |
4686 | 4686 |
4687 | 4687 |
4688 } } // namespace v8::internal | 4688 } } // namespace v8::internal |
OLD | NEW |