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

Issue 10759: Introduce text nodes (Closed)

Created:
12 years, 1 month ago by Christian Plesner Hansen
Modified:
9 years, 7 months ago
CC:
v8-dev
Visibility:
Public.

Description

Replaced atom and character class nodes by text nodes that contain a sequence of each.

Patch Set 1 #

Patch Set 2 : Fixed repeated RemoveLast issue #

Unified diffs Side-by-side diffs Delta from patch set Stats (+257 lines, -124 lines) Patch
M src/ast.h View 6 chunks +25 lines, -20 lines 0 comments Download
M src/ast.cc View 3 chunks +19 lines, -4 lines 0 comments Download
M src/jsregexp.h View 4 chunks +44 lines, -33 lines 0 comments Download
M src/jsregexp.cc View 9 chunks +105 lines, -51 lines 0 comments Download
M src/parser.cc View 1 9 chunks +61 lines, -14 lines 15 comments Download
M test/cctest/test-regexp.cc View 3 chunks +3 lines, -2 lines 0 comments Download

Messages

Total messages: 5 (0 generated)
Christian Plesner Hansen
12 years, 1 month ago (2008-11-14 21:19:30 UTC) #1
Erik Corry
LGTM
12 years, 1 month ago (2008-11-14 21:42:55 UTC) #2
Lasse Reichstein
LGTM, with comments. Primarily looked at parser.cc http://codereview.chromium.org/10759/diff/14/206 File src/parser.cc (right): http://codereview.chromium.org/10759/diff/14/206#newcode260 Line 260: last_ ...
12 years, 1 month ago (2008-11-15 23:58:06 UTC) #3
Christian Plesner Hansen
http://codereview.chromium.org/10759/diff/14/206 File src/parser.cc (right): http://codereview.chromium.org/10759/diff/14/206#newcode260 Line 260: last_ = list_->RemoveLast(); Not as such, no, but ...
12 years, 1 month ago (2008-11-16 09:05:06 UTC) #4
Lasse Reichstein
12 years, 1 month ago (2008-11-16 10:53:14 UTC) #5
http://codereview.chromium.org/10759/diff/14/206
File src/parser.cc (right):

http://codereview.chromium.org/10759/diff/14/206#newcode260
Line 260: last_ = list_->RemoveLast();
Ah, so there was a need :)

http://codereview.chromium.org/10759/diff/14/206#newcode368
Line 368: terms_.Add(text);
The current uses all have special cases for one element, where they just use
last(). If there are more than one element, they use GetList() to get all the
elements as a list, and pass it to the constructors that already happened to
expect a list (RegExpDisjunction, RegExpAlternatives).

RegExpText seems to follow the same pattern: If there is only one element, just
return that, otherwise create a wrapper RegExpText to contain the list of text
elements. If RegExpText had a constructor taking a pointer to a list, it could
choose to use that instead of creating a new list.
However, I can see that adding one RegExpText node to another might want to
flatten the resulting tree, which leads to different requirements.

http://codereview.chromium.org/10759/diff/14/206#newcode389
Line 389: void RegExpBuilder::AddTerm(RegExpTree* term) {
I can see the point. If the result of a sub-parse is a single text node, then it
might be recognized as such an added to text_ instead of terms_. So I would use
AddText to add it, and any character classes, together with setting last_ to
ADD_TEXT.

http://codereview.chromium.org/10759/diff/14/206#newcode467
Line 467: ASSERT(last_added_ == ADD_ATOM);
Indeed. It would have to be ADD_TEXT to capture that.

http://codereview.chromium.org/10759/diff/14/206#newcode3640
Line 3640: builder.AddTerm(atom);
At this point we could check whether the atom is a text node, and use a
specialized AddText instead if it is.
We can't recognize assertions and use AddAssertion, because (?:\b) is an atom
and can be quantified, even if it's ridiculous :(

Powered by Google App Engine
This is Rietveld 408576698