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

Side by Side Diff: regexp2000/src/parser.cc

Issue 8760: Experimental regexp: Use new RegExp parser to test syntax. (Closed)
Patch Set: Parses regexp using new parser. Rebased patch. 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
« no previous file with comments | « regexp2000/src/objects.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3802 matching lines...) Expand 10 before | Expand all | Expand 10 after
3813 } else { 3813 } else {
3814 Advance(); 3814 Advance();
3815 return CharacterRange::Singleton(first); 3815 return CharacterRange::Singleton(first);
3816 } 3816 }
3817 } 3817 }
3818 3818
3819 3819
3820 RegExpTree* RegExpParser::ParseCharacterClass(bool* ok) { 3820 RegExpTree* RegExpParser::ParseCharacterClass(bool* ok) {
3821 static const char* kUnterminated = "Unterminated character class"; 3821 static const char* kUnterminated = "Unterminated character class";
3822 static const char* kIllegal = "Illegal character class"; 3822 static const char* kIllegal = "Illegal character class";
3823 static const char* kRangeOutOfOrder = "Range out of order in character class";
3823 3824
3824 ASSERT_EQ(current(), '['); 3825 ASSERT_EQ(current(), '[');
3825 Advance(); 3826 Advance();
3826 bool is_negated = false; 3827 bool is_negated = false;
3827 if (current() == '^') { 3828 if (current() == '^') {
3828 is_negated = true; 3829 is_negated = true;
3829 Advance(); 3830 Advance();
3830 } 3831 }
3831 ZoneList<CharacterRange>* ranges = new ZoneList<CharacterRange>(2); 3832 ZoneList<CharacterRange>* ranges = new ZoneList<CharacterRange>(2);
3832 while (has_more() && current() != ']') { 3833 while (has_more() && current() != ']') {
3833 if (current() == '-') { 3834 if (current() == '-') {
3834 Advance(); 3835 Advance();
3835 ranges->Add(CharacterRange::Singleton('-')); 3836 ranges->Add(CharacterRange::Singleton('-'));
3836 } else { 3837 } else {
3837 CharacterRange first = ParseClassAtom(CHECK_OK); 3838 CharacterRange first = ParseClassAtom(CHECK_OK);
3838 if (!first.is_character_class() && current() == '-') { 3839 if (!first.is_character_class() && current() == '-') {
3839 Advance(); 3840 Advance();
3840 CharacterRange next = ParseClassAtom(CHECK_OK); 3841 CharacterRange next = ParseClassAtom(CHECK_OK);
3841 if (next.is_character_class()) { 3842 if (next.is_character_class()) {
3842 return ReportError(CStrVector(kIllegal), CHECK_OK); 3843 return ReportError(CStrVector(kIllegal), CHECK_OK);
3843 } 3844 }
3845 if (first.from() > next.to()) {
3846 ReportError(CStrVector(kRangeOutOfOrder), CHECK_OK);
3847 }
3844 ranges->Add(CharacterRange::Range(first.from(), next.to())); 3848 ranges->Add(CharacterRange::Range(first.from(), next.to()));
3845 } else { 3849 } else {
3846 ranges->Add(first); 3850 ranges->Add(first);
3847 } 3851 }
3848 } 3852 }
3849 } 3853 }
3850 if (!has_more()) { 3854 if (!has_more()) {
3851 return ReportError(CStrVector(kUnterminated), CHECK_OK); 3855 return ReportError(CStrVector(kUnterminated), CHECK_OK);
3852 } 3856 }
3853 Advance(); 3857 Advance();
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
3969 start_position, 3973 start_position,
3970 is_expression); 3974 is_expression);
3971 return result; 3975 return result;
3972 } 3976 }
3973 3977
3974 3978
3975 #undef NEW 3979 #undef NEW
3976 3980
3977 3981
3978 } } // namespace v8::internal 3982 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « regexp2000/src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698