OLD | NEW |
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 #include "src/regexp/regexp-parser.h" | 5 #include "src/regexp/regexp-parser.h" |
6 | 6 |
7 #include "src/char-predicates-inl.h" | 7 #include "src/char-predicates-inl.h" |
8 #include "src/factory.h" | 8 #include "src/factory.h" |
9 #include "src/isolate.h" | 9 #include "src/isolate.h" |
10 #include "src/objects-inl.h" | 10 #include "src/objects-inl.h" |
(...skipping 1673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1684 | 1684 |
1685 void RegExpBuilder::AddTerm(RegExpTree* term) { | 1685 void RegExpBuilder::AddTerm(RegExpTree* term) { |
1686 FlushText(); | 1686 FlushText(); |
1687 terms_.Add(term, zone()); | 1687 terms_.Add(term, zone()); |
1688 LAST(ADD_ATOM); | 1688 LAST(ADD_ATOM); |
1689 } | 1689 } |
1690 | 1690 |
1691 | 1691 |
1692 void RegExpBuilder::AddAssertion(RegExpTree* assert) { | 1692 void RegExpBuilder::AddAssertion(RegExpTree* assert) { |
1693 FlushText(); | 1693 FlushText(); |
| 1694 if (terms_.length() > 0 && terms_.last()->IsAssertion()) { |
| 1695 // Omit repeated assertions of the same type. |
| 1696 RegExpAssertion* last = terms_.last()->AsAssertion(); |
| 1697 RegExpAssertion* next = assert->AsAssertion(); |
| 1698 if (last->assertion_type() == next->assertion_type()) return; |
| 1699 } |
1694 terms_.Add(assert, zone()); | 1700 terms_.Add(assert, zone()); |
1695 LAST(ADD_ASSERT); | 1701 LAST(ADD_ASSERT); |
1696 } | 1702 } |
1697 | 1703 |
1698 | 1704 |
1699 void RegExpBuilder::NewAlternative() { FlushTerms(); } | 1705 void RegExpBuilder::NewAlternative() { FlushTerms(); } |
1700 | 1706 |
1701 | 1707 |
1702 void RegExpBuilder::FlushTerms() { | 1708 void RegExpBuilder::FlushTerms() { |
1703 FlushText(); | 1709 FlushText(); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1804 return false; | 1810 return false; |
1805 } | 1811 } |
1806 terms_.Add(new (zone()) RegExpQuantifier(min, max, quantifier_type, atom), | 1812 terms_.Add(new (zone()) RegExpQuantifier(min, max, quantifier_type, atom), |
1807 zone()); | 1813 zone()); |
1808 LAST(ADD_TERM); | 1814 LAST(ADD_TERM); |
1809 return true; | 1815 return true; |
1810 } | 1816 } |
1811 | 1817 |
1812 } // namespace internal | 1818 } // namespace internal |
1813 } // namespace v8 | 1819 } // namespace v8 |
OLD | NEW |