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

Unified Diff: runtime/vm/regexp_parser.h

Issue 754383002: Revert "Integrate the Irregexp Regular Expression Engine." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/regexp_ast.cc ('k') | runtime/vm/regexp_parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/regexp_parser.h
diff --git a/runtime/vm/regexp_parser.h b/runtime/vm/regexp_parser.h
index 3030782b881a24db920be4002b351f0e58a7aee9..42cedd4d3469e01eba9ceee433280c6d063d7e91 100644
--- a/runtime/vm/regexp_parser.h
+++ b/runtime/vm/regexp_parser.h
@@ -5,18 +5,17 @@
#ifndef VM_REGEXP_PARSER_H_
#define VM_REGEXP_PARSER_H_
-#include "vm/allocation.h"
-#include "vm/growable_array.h"
-#include "vm/regexp_ast.h"
+// SNIP
namespace dart {
+// SNIP
+
// Accumulates RegExp atoms and assertions into lists of terms and alternatives.
-class RegExpBuilder: public ZoneAllocated {
+class RegExpBuilder: public ZoneObject {
public:
- RegExpBuilder();
-
- void AddCharacter(uint16_t character);
+ explicit RegExpBuilder(Zone* zone);
+ void AddCharacter(uc16 character);
// "Adds" an empty expression. Does nothing except consume a
// following quantifier
void AddEmpty();
@@ -24,22 +23,21 @@ class RegExpBuilder: public ZoneAllocated {
void AddAssertion(RegExpTree* tree);
void NewAlternative(); // '|'
void AddQuantifierToAtom(
- intptr_t min, intptr_t max, RegExpQuantifier::QuantifierType type);
+ int min, int max, RegExpQuantifier::QuantifierType type);
RegExpTree* ToRegExp();
private:
void FlushCharacters();
void FlushText();
void FlushTerms();
+ Zone* zone() const { return zone_; }
- Isolate* isolate() const { return isolate_; }
-
- Isolate* isolate_;
+ Zone* zone_;
bool pending_empty_;
- ZoneGrowableArray<uint16_t>* characters_;
- GrowableArray<RegExpTree*> terms_;
- GrowableArray<RegExpTree*> text_;
- GrowableArray<RegExpTree*> alternatives_;
+ ZoneList<uc16>* characters_;
+ BufferedZoneList<RegExpTree, 2> terms_;
+ BufferedZoneList<RegExpTree, 2> text_;
+ BufferedZoneList<RegExpTree, 2> alternatives_;
#ifdef DEBUG
enum {ADD_NONE, ADD_CHAR, ADD_TERM, ADD_ASSERT, ADD_ATOM} last_added_;
#define LAST(x) last_added_ = x;
@@ -48,17 +46,18 @@ class RegExpBuilder: public ZoneAllocated {
#endif
};
-class RegExpParser : public ValueObject {
- public:
- RegExpParser(const String& in,
- String* error,
- bool multiline_mode);
- static bool ParseFunction(ParsedFunction* parsed_function);
+class RegExpParser BASE_EMBEDDED {
+ public:
+ RegExpParser(FlatStringReader* in,
+ Handle<String>* error,
+ bool multiline_mode,
+ Zone* zone);
- static bool ParseRegExp(const String& input,
+ static bool ParseRegExp(FlatStringReader* input,
bool multiline,
- RegExpCompileData* result);
+ RegExpCompileData* result,
+ Zone* zone);
RegExpTree* ParsePattern();
RegExpTree* ParseDisjunction();
@@ -67,42 +66,41 @@ class RegExpParser : public ValueObject {
// Parses a {...,...} quantifier and stores the range in the given
// out parameters.
- bool ParseIntervalQuantifier(intptr_t* min_out, intptr_t* max_out);
+ bool ParseIntervalQuantifier(int* min_out, int* max_out);
// Parses and returns a single escaped character. The character
// must not be 'b' or 'B' since they are usually handle specially.
- uint32_t ParseClassCharacterEscape();
+ uc32 ParseClassCharacterEscape();
// Checks whether the following is a length-digit hexadecimal number,
// and sets the value if it is.
- bool ParseHexEscape(intptr_t length, uint32_t* value);
+ bool ParseHexEscape(int length, uc32* value);
- uint32_t ParseOctalLiteral();
+ uc32 ParseOctalLiteral();
// Tries to parse the input as a back reference. If successful it
// stores the result in the output parameter and returns true. If
// it fails it will push back the characters read so the same characters
// can be reparsed.
- bool ParseBackReferenceIndex(intptr_t* index_out);
+ bool ParseBackReferenceIndex(int* index_out);
- CharacterRange ParseClassAtom(uint16_t* char_class);
- void ReportError(const char* message);
+ CharacterRange ParseClassAtom(uc16* char_class);
+ RegExpTree* ReportError(Vector<const char> message);
void Advance();
- void Advance(intptr_t dist);
- void Reset(intptr_t pos);
+ void Advance(int dist);
+ void Reset(int pos);
// Reports whether the pattern might be used as a literal search string.
// Only use if the result of the parse is a single atom node.
bool simple();
bool contains_anchor() { return contains_anchor_; }
void set_contains_anchor() { contains_anchor_ = true; }
- intptr_t captures_started() { return captures_ == NULL ?
- 0 : captures_->length(); }
- intptr_t position() { return next_pos_ - 1; }
+ int captures_started() { return captures_ == NULL ? 0 : captures_->length(); }
+ int position() { return next_pos_ - 1; }
bool failed() { return failed_; }
- static const intptr_t kMaxCaptures = 1 << 16;
- static const uint32_t kEndMarker = (1 << 21);
+ static const int kMaxCaptures = 1 << 16;
+ static const uc32 kEndMarker = (1 << 21);
private:
enum SubexpressionType {
@@ -113,14 +111,14 @@ class RegExpParser : public ValueObject {
GROUPING
};
- class RegExpParserState : public ZoneAllocated {
+ class RegExpParserState : public ZoneObject {
public:
RegExpParserState(RegExpParserState* previous_state,
SubexpressionType group_type,
- intptr_t disjunction_capture_index,
- Isolate *isolate)
+ int disjunction_capture_index,
+ Zone* zone)
: previous_state_(previous_state),
- builder_(new(isolate) RegExpBuilder()),
+ builder_(new(zone) RegExpBuilder(zone)),
group_type_(group_type),
disjunction_capture_index_(disjunction_capture_index) {}
// Parser state of containing expression, if any.
@@ -133,7 +131,7 @@ class RegExpParser : public ValueObject {
// Index in captures array of first capture in this sub-expression, if any.
// Also the capture index of this sub-expression itself, if group_type
// is CAPTURE.
- intptr_t capture_index() { return disjunction_capture_index_; }
+ int capture_index() { return disjunction_capture_index_; }
private:
// Linked list implementation of stack of states.
@@ -143,26 +141,28 @@ class RegExpParser : public ValueObject {
// Stored disjunction type (capture, look-ahead or grouping), if any.
SubexpressionType group_type_;
// Stored disjunction's capture index (if any).
- intptr_t disjunction_capture_index_;
+ int disjunction_capture_index_;
};
Isolate* isolate() { return isolate_; }
+ Zone* zone() const { return zone_; }
- uint32_t current() { return current_; }
+ uc32 current() { return current_; }
bool has_more() { return has_more_; }
- bool has_next() { return next_pos_ < in().Length(); }
- uint32_t Next();
- const String& in() { return in_; }
+ bool has_next() { return next_pos_ < in()->length(); }
+ uc32 Next();
+ FlatStringReader* in() { return in_; }
void ScanForCaptures();
Isolate* isolate_;
- String* error_;
- ZoneGrowableArray<RegExpCapture*>* captures_;
- const String& in_;
- uint32_t current_;
- intptr_t next_pos_;
+ Zone* zone_;
+ Handle<String>* error_;
+ ZoneList<RegExpCapture*>* captures_;
+ FlatStringReader* in_;
+ uc32 current_;
+ int next_pos_;
// The capture count is only valid after we have scanned for captures.
- intptr_t capture_count_;
+ int capture_count_;
bool has_more_;
bool multiline_;
bool simple_;
@@ -171,6 +171,8 @@ class RegExpParser : public ValueObject {
bool failed_;
};
+// SNIP
+
} // namespace dart
#endif // VM_REGEXP_PARSER_H_
« no previous file with comments | « runtime/vm/regexp_ast.cc ('k') | runtime/vm/regexp_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698