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

Unified Diff: src/ast.h

Issue 10759: Introduce text nodes (Closed)
Patch Set: Fixed repeated RemoveLast issue 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/ast.cc » ('j') | src/parser.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast.h
diff --git a/src/ast.h b/src/ast.h
index 2264eb1e1bbe5be730d0f46f6ec1f599ebb77bef..68b13732a13a5631fbd89131b7b24e9ec9a68c59 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -1191,24 +1191,6 @@ class ThisFunction: public Expression {
// Regular expressions
-#define FOR_EACH_REG_EXP_NODE_TYPE(VISIT) \
- VISIT(Disjunction) \
- VISIT(Alternative) \
- VISIT(Assertion) \
- VISIT(CharacterClass) \
- VISIT(Atom) \
- VISIT(Quantifier) \
- VISIT(Capture) \
- VISIT(Lookahead) \
- VISIT(Backreference) \
- VISIT(Empty)
-
-
-#define FORWARD_DECLARE(Name) class RegExp##Name;
-FOR_EACH_REG_EXP_NODE_TYPE(FORWARD_DECLARE)
-#undef FORWARD_DECLARE
-
-
class RegExpTree: public ZoneObject {
public:
virtual ~RegExpTree() { }
@@ -1216,9 +1198,11 @@ class RegExpTree: public ZoneObject {
virtual RegExpNode* ToNode(RegExpCompiler* compiler,
RegExpNode* on_success,
RegExpNode* on_failure) = 0;
+ virtual bool IsTextElement() { return false; }
+ virtual void AppendToText(RegExpText* text);
SmartPointer<const char> ToString();
#define MAKE_ASTYPE(Name) virtual RegExp##Name* As##Name();
- FOR_EACH_REG_EXP_NODE_TYPE(MAKE_ASTYPE)
+ FOR_EACH_REG_EXP_TREE_TYPE(MAKE_ASTYPE)
#undef MAKE_ASTYPE
};
@@ -1252,6 +1236,23 @@ class RegExpAlternative: public RegExpTree {
};
+class RegExpText: public RegExpTree {
+ public:
+ RegExpText() : elements_(2) { }
+ virtual void* Accept(RegExpVisitor* visitor, void* data);
+ virtual RegExpNode* ToNode(RegExpCompiler* compiler,
+ RegExpNode* on_success,
+ RegExpNode* on_failure);
+ virtual RegExpText* AsText();
+ virtual bool IsTextElement() { return true; }
+ virtual void AppendToText(RegExpText* text);
+ void AddElement(TextElement elm) { elements_.Add(elm); }
+ ZoneList<TextElement>* elements() { return &elements_; }
+ private:
+ ZoneList<TextElement> elements_;
+};
+
+
class RegExpAssertion: public RegExpTree {
public:
enum Type {
@@ -1285,6 +1286,8 @@ class RegExpCharacterClass: public RegExpTree {
RegExpNode* on_success,
RegExpNode* on_failure);
virtual RegExpCharacterClass* AsCharacterClass();
+ virtual bool IsTextElement() { return true; }
+ virtual void AppendToText(RegExpText* text);
ZoneList<CharacterRange>* ranges() { return ranges_; }
bool is_negated() { return is_negated_; }
private:
@@ -1301,6 +1304,8 @@ class RegExpAtom: public RegExpTree {
RegExpNode* on_success,
RegExpNode* on_failure);
virtual RegExpAtom* AsAtom();
+ virtual bool IsTextElement() { return true; }
+ virtual void AppendToText(RegExpText* text);
Vector<const uc16> data() { return data_; }
private:
Vector<const uc16> data_;
@@ -1426,7 +1431,7 @@ class RegExpVisitor BASE_EMBEDDED {
virtual ~RegExpVisitor() { }
#define MAKE_CASE(Name) \
virtual void* Visit##Name(RegExp##Name*, void* data) = 0;
- FOR_EACH_REG_EXP_NODE_TYPE(MAKE_CASE)
+ FOR_EACH_REG_EXP_TREE_TYPE(MAKE_CASE)
#undef MAKE_CASE
};
« no previous file with comments | « no previous file | src/ast.cc » ('j') | src/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698