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

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

Issue 2636883002: [regexp] Implement regexp groups as wrapper. (Closed)
Patch Set: fix Created 3 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
« no previous file with comments | « no previous file | src/regexp/regexp-ast.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_AST_H_ 5 #ifndef V8_REGEXP_REGEXP_AST_H_
6 #define V8_REGEXP_REGEXP_AST_H_ 6 #define V8_REGEXP_REGEXP_AST_H_
7 7
8 #include "src/objects.h" 8 #include "src/objects.h"
9 #include "src/utils.h" 9 #include "src/utils.h"
10 #include "src/zone/zone-containers.h" 10 #include "src/zone/zone-containers.h"
11 #include "src/zone/zone.h" 11 #include "src/zone/zone.h"
12 12
13 namespace v8 { 13 namespace v8 {
14 namespace internal { 14 namespace internal {
15 15
16 #define FOR_EACH_REG_EXP_TREE_TYPE(VISIT) \ 16 #define FOR_EACH_REG_EXP_TREE_TYPE(VISIT) \
17 VISIT(Disjunction) \ 17 VISIT(Disjunction) \
18 VISIT(Alternative) \ 18 VISIT(Alternative) \
19 VISIT(Assertion) \ 19 VISIT(Assertion) \
20 VISIT(CharacterClass) \ 20 VISIT(CharacterClass) \
21 VISIT(Atom) \ 21 VISIT(Atom) \
22 VISIT(Quantifier) \ 22 VISIT(Quantifier) \
23 VISIT(Capture) \ 23 VISIT(Capture) \
24 VISIT(Group) \
24 VISIT(Lookaround) \ 25 VISIT(Lookaround) \
25 VISIT(BackReference) \ 26 VISIT(BackReference) \
26 VISIT(Empty) \ 27 VISIT(Empty) \
27 VISIT(Text) 28 VISIT(Text)
28 29
29
30 #define FORWARD_DECLARE(Name) class RegExp##Name; 30 #define FORWARD_DECLARE(Name) class RegExp##Name;
31 FOR_EACH_REG_EXP_TREE_TYPE(FORWARD_DECLARE) 31 FOR_EACH_REG_EXP_TREE_TYPE(FORWARD_DECLARE)
32 #undef FORWARD_DECLARE 32 #undef FORWARD_DECLARE
33 33
34 class RegExpCompiler; 34 class RegExpCompiler;
35 class RegExpNode; 35 class RegExpNode;
36 class RegExpTree; 36 class RegExpTree;
37 37
38 38
39 class RegExpVisitor BASE_EMBEDDED { 39 class RegExpVisitor BASE_EMBEDDED {
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 void set_name(const ZoneVector<uc16>* name) { name_ = name; } 433 void set_name(const ZoneVector<uc16>* name) { name_ = name; }
434 static int StartRegister(int index) { return index * 2; } 434 static int StartRegister(int index) { return index * 2; }
435 static int EndRegister(int index) { return index * 2 + 1; } 435 static int EndRegister(int index) { return index * 2 + 1; }
436 436
437 private: 437 private:
438 RegExpTree* body_; 438 RegExpTree* body_;
439 int index_; 439 int index_;
440 const ZoneVector<uc16>* name_; 440 const ZoneVector<uc16>* name_;
441 }; 441 };
442 442
443 class RegExpGroup final : public RegExpTree {
444 public:
445 explicit RegExpGroup(RegExpTree* body) : body_(body) {}
446 void* Accept(RegExpVisitor* visitor, void* data) override;
447 RegExpNode* ToNode(RegExpCompiler* compiler,
448 RegExpNode* on_success) override {
449 return body_->ToNode(compiler, on_success);
450 }
451 RegExpGroup* AsGroup() override;
452 bool IsAnchoredAtStart() override { return body_->IsAnchoredAtStart(); }
453 bool IsAnchoredAtEnd() override { return body_->IsAnchoredAtEnd(); }
454 bool IsGroup() override;
455 int min_match() override { return body_->min_match(); }
456 int max_match() override { return body_->max_match(); }
457 Interval CaptureRegisters() override { return body_->CaptureRegisters(); }
458 RegExpTree* body() { return body_; }
459
460 private:
461 RegExpTree* body_;
462 };
443 463
444 class RegExpLookaround final : public RegExpTree { 464 class RegExpLookaround final : public RegExpTree {
445 public: 465 public:
446 enum Type { LOOKAHEAD, LOOKBEHIND }; 466 enum Type { LOOKAHEAD, LOOKBEHIND };
447 467
448 RegExpLookaround(RegExpTree* body, bool is_positive, int capture_count, 468 RegExpLookaround(RegExpTree* body, bool is_positive, int capture_count,
449 int capture_from, Type type) 469 int capture_from, Type type)
450 : body_(body), 470 : body_(body),
451 is_positive_(is_positive), 471 is_positive_(is_positive),
452 capture_count_(capture_count), 472 capture_count_(capture_count),
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 RegExpEmpty* AsEmpty() override; 545 RegExpEmpty* AsEmpty() override;
526 bool IsEmpty() override; 546 bool IsEmpty() override;
527 int min_match() override { return 0; } 547 int min_match() override { return 0; }
528 int max_match() override { return 0; } 548 int max_match() override { return 0; }
529 }; 549 };
530 550
531 } // namespace internal 551 } // namespace internal
532 } // namespace v8 552 } // namespace v8
533 553
534 #endif // V8_REGEXP_REGEXP_AST_H_ 554 #endif // V8_REGEXP_REGEXP_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/regexp/regexp-ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698