OLD | NEW |
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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 AddCharacterClassForDesugaring(uc32 c); | 109 void AddCharacterClassForDesugaring(uc32 c); |
110 void AddAtom(RegExpTree* tree); | 110 void AddAtom(RegExpTree* tree); |
111 void AddTerm(RegExpTree* tree); | 111 void AddTerm(RegExpTree* tree); |
112 void AddAssertion(RegExpTree* tree); | 112 void AddAssertion(RegExpTree* tree); |
113 void NewAlternative(); // '|' | 113 void NewAlternative(); // '|' |
114 void AddQuantifierToAtom(int min, int max, | 114 bool AddQuantifierToAtom(int min, int max, |
115 RegExpQuantifier::QuantifierType type); | 115 RegExpQuantifier::QuantifierType type); |
116 RegExpTree* ToRegExp(); | 116 RegExpTree* ToRegExp(); |
117 | 117 |
118 private: | 118 private: |
119 static const uc16 kNoPendingSurrogate = 0; | 119 static const uc16 kNoPendingSurrogate = 0; |
120 void AddLeadSurrogate(uc16 lead_surrogate); | 120 void AddLeadSurrogate(uc16 lead_surrogate); |
121 void AddTrailSurrogate(uc16 trail_surrogate); | 121 void AddTrailSurrogate(uc16 trail_surrogate); |
122 void FlushPendingSurrogate(); | 122 void FlushPendingSurrogate(); |
123 void FlushCharacters(); | 123 void FlushCharacters(); |
124 void FlushText(); | 124 void FlushText(); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 // Only use if the result of the parse is a single atom node. | 191 // Only use if the result of the parse is a single atom node. |
192 bool simple(); | 192 bool simple(); |
193 bool contains_anchor() { return contains_anchor_; } | 193 bool contains_anchor() { return contains_anchor_; } |
194 void set_contains_anchor() { contains_anchor_ = true; } | 194 void set_contains_anchor() { contains_anchor_ = true; } |
195 int captures_started() { return captures_started_; } | 195 int captures_started() { return captures_started_; } |
196 int position() { return next_pos_ - 1; } | 196 int position() { return next_pos_ - 1; } |
197 bool failed() { return failed_; } | 197 bool failed() { return failed_; } |
198 bool unicode() const { return (flags_ & JSRegExp::kUnicode) != 0; } | 198 bool unicode() const { return (flags_ & JSRegExp::kUnicode) != 0; } |
199 bool multiline() const { return (flags_ & JSRegExp::kMultiline) != 0; } | 199 bool multiline() const { return (flags_ & JSRegExp::kMultiline) != 0; } |
200 | 200 |
201 static bool IsSyntaxCharacter(uc32 c); | 201 static bool IsSyntaxCharacterOrSlash(uc32 c); |
202 | 202 |
203 static const int kMaxCaptures = 1 << 16; | 203 static const int kMaxCaptures = 1 << 16; |
204 static const uc32 kEndMarker = (1 << 21); | 204 static const uc32 kEndMarker = (1 << 21); |
205 | 205 |
206 private: | 206 private: |
207 enum SubexpressionType { | 207 enum SubexpressionType { |
208 INITIAL, | 208 INITIAL, |
209 CAPTURE, // All positive values represent captures. | 209 CAPTURE, // All positive values represent captures. |
210 POSITIVE_LOOKAROUND, | 210 POSITIVE_LOOKAROUND, |
211 NEGATIVE_LOOKAROUND, | 211 NEGATIVE_LOOKAROUND, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 bool simple_; | 284 bool simple_; |
285 bool contains_anchor_; | 285 bool contains_anchor_; |
286 bool is_scanned_for_captures_; | 286 bool is_scanned_for_captures_; |
287 bool failed_; | 287 bool failed_; |
288 }; | 288 }; |
289 | 289 |
290 } // namespace internal | 290 } // namespace internal |
291 } // namespace v8 | 291 } // namespace v8 |
292 | 292 |
293 #endif // V8_REGEXP_REGEXP_PARSER_H_ | 293 #endif // V8_REGEXP_REGEXP_PARSER_H_ |
OLD | NEW |