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

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

Issue 2050343002: [regexp] Experimental support for regexp named captures (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Proper fixed array cast Created 4 years, 6 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
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.h" 10 #include "src/zone.h"
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 RegExpCapture* AsCapture() override; 420 RegExpCapture* AsCapture() override;
421 bool IsAnchoredAtStart() override; 421 bool IsAnchoredAtStart() override;
422 bool IsAnchoredAtEnd() override; 422 bool IsAnchoredAtEnd() override;
423 Interval CaptureRegisters() override; 423 Interval CaptureRegisters() override;
424 bool IsCapture() override; 424 bool IsCapture() override;
425 int min_match() override { return body_->min_match(); } 425 int min_match() override { return body_->min_match(); }
426 int max_match() override { return body_->max_match(); } 426 int max_match() override { return body_->max_match(); }
427 RegExpTree* body() { return body_; } 427 RegExpTree* body() { return body_; }
428 void set_body(RegExpTree* body) { body_ = body; } 428 void set_body(RegExpTree* body) { body_ = body; }
429 int index() { return index_; } 429 int index() { return index_; }
430 Vector<const uc16> name() const { return name_; }
431 void set_name(Vector<const uc16> name) { name_ = name; }
430 static int StartRegister(int index) { return index * 2; } 432 static int StartRegister(int index) { return index * 2; }
431 static int EndRegister(int index) { return index * 2 + 1; } 433 static int EndRegister(int index) { return index * 2 + 1; }
432 434
433 private: 435 private:
434 RegExpTree* body_; 436 RegExpTree* body_;
435 int index_; 437 int index_;
438 Vector<const uc16> name_;
436 }; 439 };
437 440
438 441
439 class RegExpLookaround final : public RegExpTree { 442 class RegExpLookaround final : public RegExpTree {
440 public: 443 public:
441 enum Type { LOOKAHEAD, LOOKBEHIND }; 444 enum Type { LOOKAHEAD, LOOKBEHIND };
442 445
443 RegExpLookaround(RegExpTree* body, bool is_positive, int capture_count, 446 RegExpLookaround(RegExpTree* body, bool is_positive, int capture_count,
444 int capture_from, Type type) 447 int capture_from, Type type)
445 : body_(body), 448 : body_(body),
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 RegExpTree* body_; 485 RegExpTree* body_;
483 bool is_positive_; 486 bool is_positive_;
484 int capture_count_; 487 int capture_count_;
485 int capture_from_; 488 int capture_from_;
486 Type type_; 489 Type type_;
487 }; 490 };
488 491
489 492
490 class RegExpBackReference final : public RegExpTree { 493 class RegExpBackReference final : public RegExpTree {
491 public: 494 public:
495 RegExpBackReference() : capture_(nullptr) {}
492 explicit RegExpBackReference(RegExpCapture* capture) : capture_(capture) {} 496 explicit RegExpBackReference(RegExpCapture* capture) : capture_(capture) {}
493 void* Accept(RegExpVisitor* visitor, void* data) override; 497 void* Accept(RegExpVisitor* visitor, void* data) override;
494 RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success) override; 498 RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success) override;
495 RegExpBackReference* AsBackReference() override; 499 RegExpBackReference* AsBackReference() override;
496 bool IsBackReference() override; 500 bool IsBackReference() override;
497 int min_match() override { return 0; } 501 int min_match() override { return 0; }
498 // The back reference may be recursive, e.g. /(\2)(\1)/. To avoid infinite 502 // The back reference may be recursive, e.g. /(\2)(\1)/. To avoid infinite
499 // recursion, we give up. Ignorance is bliss. 503 // recursion, we give up. Ignorance is bliss.
500 int max_match() override { return kInfinity; } 504 int max_match() override { return kInfinity; }
501 int index() { return capture_->index(); } 505 int index() { return capture_->index(); }
502 RegExpCapture* capture() { return capture_; } 506 RegExpCapture* capture() { return capture_; }
507 void set_capture(RegExpCapture* capture) { capture_ = capture; }
508 Vector<const uc16> name() const { return name_; }
509 void set_name(Vector<const uc16> name) { name_ = name; }
503 510
504 private: 511 private:
505 RegExpCapture* capture_; 512 RegExpCapture* capture_;
513 Vector<const uc16> name_;
506 }; 514 };
507 515
508 516
509 class RegExpEmpty final : public RegExpTree { 517 class RegExpEmpty final : public RegExpTree {
510 public: 518 public:
511 RegExpEmpty() {} 519 RegExpEmpty() {}
512 void* Accept(RegExpVisitor* visitor, void* data) override; 520 void* Accept(RegExpVisitor* visitor, void* data) override;
513 RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success) override; 521 RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success) override;
514 RegExpEmpty* AsEmpty() override; 522 RegExpEmpty* AsEmpty() override;
515 bool IsEmpty() override; 523 bool IsEmpty() override;
516 int min_match() override { return 0; } 524 int min_match() override { return 0; }
517 int max_match() override { return 0; } 525 int max_match() override { return 0; }
518 }; 526 };
519 527
520 } // namespace internal 528 } // namespace internal
521 } // namespace v8 529 } // namespace v8
522 530
523 #endif // V8_REGEXP_REGEXP_AST_H_ 531 #endif // V8_REGEXP_REGEXP_AST_H_
OLDNEW
« no previous file with comments | « src/regexp/jsregexp.cc ('k') | src/regexp/regexp-parser.h » ('j') | src/regexp/regexp-parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698