5#ifndef RUNTIME_VM_REGEXP_PARSER_H_
6#define RUNTIME_VM_REGEXP_PARSER_H_
44 static constexpr uint16_t kNoPendingSurrogate = 0;
45 void AddLeadSurrogate(uint16_t lead_surrogate);
46 void AddTrailSurrogate(uint16_t trail_surrogate);
47 void FlushPendingSurrogate();
48 void FlushCharacters();
52 bool NeedsDesugaringForIgnoreCase(uint32_t c);
54 Zone* zone()
const {
return zone_; }
55 bool is_unicode()
const {
return flags_.
IsUnicode(); }
60 ZoneGrowableArray<uint16_t>* characters_;
61 uint16_t pending_surrogate_;
62 GrowableArray<RegExpTree*> terms_;
63 GrowableArray<RegExpTree*> text_;
64 GrowableArray<RegExpTree*> alternatives_;
66 enum { ADD_NONE, ADD_CHAR, ADD_TERM, ADD_ASSERT, ADD_ATOM } last_added_;
67#define LAST(x) last_added_ = x;
127 bool add_unicode_case_equivalents,
149 enum SubexpressionType {
159 RegExpParserState(RegExpParserState* previous_state,
160 SubexpressionType group_type,
162 intptr_t disjunction_capture_index,
166 : previous_state_(previous_state),
168 group_type_(group_type),
169 lookaround_type_(lookaround_type),
170 disjunction_capture_index_(disjunction_capture_index),
171 capture_name_(capture_name) {}
173 RegExpParserState* previous_state() {
return previous_state_; }
174 bool IsSubexpression() {
return previous_state_ !=
nullptr; }
176 RegExpBuilder*
builder() {
return builder_; }
178 SubexpressionType group_type() {
return group_type_; }
184 intptr_t capture_index() {
return disjunction_capture_index_; }
187 bool IsNamedCapture()
const {
return capture_name_ !=
nullptr; }
190 bool IsInsideCaptureGroup(intptr_t index);
196 RegExpParserState* previous_state_;
198 RegExpBuilder* builder_;
200 SubexpressionType group_type_;
204 intptr_t disjunction_capture_index_;
210 RegExpCapture* GetCapture(intptr_t index);
221 bool ParseNamedBackReference(RegExpBuilder*
builder,
222 RegExpParserState*
state);
223 RegExpParserState* ParseOpenParenthesis(RegExpParserState*
state);
229 void PatchNamedBackReferences();
231 ArrayPtr CreateCaptureNameMap();
235 bool HasNamedCaptures();
237 Zone* zone() {
return zone_; }
239 uint32_t current() {
return current_; }
240 bool has_more() {
return has_more_; }
241 bool has_next() {
return next_pos_ < in().
Length(); }
243 uint32_t ReadNext(
bool update_position);
244 const String& in() {
return in_; }
245 void ScanForCaptures();
248 ZoneGrowableArray<RegExpCapture*>* captures_;
249 ZoneGrowableArray<RegExpCapture*>* named_captures_;
250 ZoneGrowableArray<RegExpBackReference*>* named_back_references_;
254 intptr_t captures_started_;
256 intptr_t capture_count_;
258 RegExpFlags top_level_flags_;
260 bool contains_anchor_;
261 bool is_scanned_for_captures_;
262 bool has_named_captures_;
void AddAssertion(RegExpTree *tree)
void AddCharacterClass(RegExpCharacterClass *cc)
bool AddQuantifierToAtom(intptr_t min, intptr_t max, RegExpQuantifier::QuantifierType type)
void AddCharacterClassForDesugaring(uint32_t c)
void AddTerm(RegExpTree *tree)
RegExpBuilder(RegExpFlags flags)
RegExpFlags flags() const
bool is_multi_line() const
void AddEscapedUnicodeCharacter(uint32_t character)
void AddUnicodeCharacter(uint32_t character)
void AddAtom(RegExpTree *tree)
void AddCharacter(uint16_t character)
uint32_t ParseOctalLiteral()
void ReportError(const char *message)
RegExpTree * GetPropertySequence(ZoneGrowableArray< char > *name_1)
RegExpTree * ParseDisjunction()
RegExpParser(const String &in, String *error, RegExpFlags regexp_flags)
bool ParseClassEscape(ZoneGrowableArray< CharacterRange > *ranges, bool add_unicode_case_equivalents, uint32_t *char_out)
RegExpTree * ParseGroup()
RegExpTree * ParsePattern()
void set_contains_anchor()
bool ParseUnlimitedLengthHexNumber(uint32_t max_value, uint32_t *value)
bool ParseHexEscape(intptr_t length, uint32_t *value)
uint32_t ParseClassCharacterEscape()
bool ParseIntervalQuantifier(intptr_t *min_out, intptr_t *max_out)
static bool IsSyntaxCharacterOrSlash(uint32_t c)
bool AddPropertyClassRange(ZoneGrowableArray< CharacterRange > *add_to, bool negate, ZoneGrowableArray< char > *name_1, ZoneGrowableArray< char > *name_2)
static constexpr uint32_t kEndMarker
bool ParseUnicodeEscape(uint32_t *value)
bool ParseBackReferenceIndex(intptr_t *index_out)
RegExpTree * ParseCharacterClass(const RegExpBuilder *builder)
static constexpr intptr_t kMaxCaptures
static void ParseRegExp(const String &input, RegExpFlags regexp_flags, RegExpCompileData *result)
bool ParsePropertyClassName(ZoneGrowableArray< char > *name_1, ZoneGrowableArray< char > *name_2)
intptr_t captures_started()
FlutterSemanticsFlag flags
const uint8_t uint32_t uint32_t GError ** error
static float max(float r, float g, float b)
static float min(float r, float g, float b)
ZoneGrowableArray< uint16_t > RegExpCaptureName