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

Side by Side Diff: src/regexp/regexp-parser.h

Issue 1599303002: [regexp] implement case-insensitive unicode regexps. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@unicodeclass
Patch Set: fix mips Created 4 years, 11 months 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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_REGEXP_REGEXP_PARSER_H_ 5 #ifndef V8_REGEXP_REGEXP_PARSER_H_
6 #define V8_REGEXP_REGEXP_PARSER_H_ 6 #define V8_REGEXP_REGEXP_PARSER_H_
7 7
8 #include "src/objects.h" 8 #include "src/objects.h"
9 #include "src/regexp/regexp-ast.h" 9 #include "src/regexp/regexp-ast.h"
10 #include "src/zone.h" 10 #include "src/zone.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 // Accumulates RegExp atoms and assertions into lists of terms and alternatives. 99 // Accumulates RegExp atoms and assertions into lists of terms and alternatives.
100 class RegExpBuilder : public ZoneObject { 100 class RegExpBuilder : public ZoneObject {
101 public: 101 public:
102 RegExpBuilder(Zone* zone, JSRegExp::Flags flags); 102 RegExpBuilder(Zone* zone, JSRegExp::Flags flags);
103 void AddCharacter(uc16 character); 103 void AddCharacter(uc16 character);
104 void AddUnicodeCharacter(uc32 character); 104 void AddUnicodeCharacter(uc32 character);
105 // "Adds" an empty expression. Does nothing except consume a 105 // "Adds" an empty expression. Does nothing except consume a
106 // following quantifier 106 // following quantifier
107 void AddEmpty(); 107 void AddEmpty();
108 void AddCharacterClass(RegExpCharacterClass* cc); 108 void AddCharacterClass(RegExpCharacterClass* cc);
109 void AddCharacterClass(uc32 c);
109 void AddAtom(RegExpTree* tree); 110 void AddAtom(RegExpTree* tree);
110 void AddTerm(RegExpTree* tree); 111 void AddTerm(RegExpTree* tree);
111 void AddAssertion(RegExpTree* tree); 112 void AddAssertion(RegExpTree* tree);
112 void NewAlternative(); // '|' 113 void NewAlternative(); // '|'
113 void AddQuantifierToAtom(int min, int max, 114 void AddQuantifierToAtom(int min, int max,
114 RegExpQuantifier::QuantifierType type); 115 RegExpQuantifier::QuantifierType type);
115 RegExpTree* ToRegExp(); 116 RegExpTree* ToRegExp();
116 117
117 private: 118 private:
118 static const uc16 kNoPendingSurrogate = 0; 119 static const uc16 kNoPendingSurrogate = 0;
119 void AddLeadSurrogate(uc16 lead_surrogate); 120 void AddLeadSurrogate(uc16 lead_surrogate);
120 void AddTrailSurrogate(uc16 trail_surrogate); 121 void AddTrailSurrogate(uc16 trail_surrogate);
121 void FlushPendingSurrogate(); 122 void FlushPendingSurrogate();
122 void FlushCharacters(); 123 void FlushCharacters();
123 void FlushText(); 124 void FlushText();
124 void FlushTerms(); 125 void FlushTerms();
126 bool NeedsDesugaringForUnicode(ZoneList<CharacterRange>* ranges);
127 bool NeedsDesugaringForIgnoreCase(uc32 c);
125 Zone* zone() const { return zone_; } 128 Zone* zone() const { return zone_; }
126 bool unicode() const { return (flags_ & JSRegExp::kUnicode) != 0; } 129 bool unicode() const { return (flags_ & JSRegExp::kUnicode) != 0; }
130 bool ignore_case() const { return (flags_ & JSRegExp::kIgnoreCase) != 0; }
127 131
128 Zone* zone_; 132 Zone* zone_;
129 bool pending_empty_; 133 bool pending_empty_;
130 JSRegExp::Flags flags_; 134 JSRegExp::Flags flags_;
131 ZoneList<uc16>* characters_; 135 ZoneList<uc16>* characters_;
132 uc16 pending_surrogate_; 136 uc16 pending_surrogate_;
133 BufferedZoneList<RegExpTree, 2> terms_; 137 BufferedZoneList<RegExpTree, 2> terms_;
134 BufferedZoneList<RegExpTree, 2> text_; 138 BufferedZoneList<RegExpTree, 2> text_;
135 BufferedZoneList<RegExpTree, 2> alternatives_; 139 BufferedZoneList<RegExpTree, 2> alternatives_;
136 #ifdef DEBUG 140 #ifdef DEBUG
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 bool simple_; 284 bool simple_;
281 bool contains_anchor_; 285 bool contains_anchor_;
282 bool is_scanned_for_captures_; 286 bool is_scanned_for_captures_;
283 bool failed_; 287 bool failed_;
284 }; 288 };
285 289
286 } // namespace internal 290 } // namespace internal
287 } // namespace v8 291 } // namespace v8
288 292
289 #endif // V8_REGEXP_REGEXP_PARSER_H_ 293 #endif // V8_REGEXP_REGEXP_PARSER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698