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

Side by Side Diff: src/scanner.cc

Issue 11316: Merged bleeding edge 746:795 into regexp2000. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/regexp2000/
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/runtime.cc ('k') | src/stub-cache.h » ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 c0_ = source_.Advance(); 227 c0_ = source_.Advance();
228 } 228 }
229 229
230 230
231 void Scanner::PushBack(uc32 ch) { 231 void Scanner::PushBack(uc32 ch) {
232 source_.PushBack(ch); 232 source_.PushBack(ch);
233 c0_ = ch; 233 c0_ = ch;
234 } 234 }
235 235
236 236
237 static inline bool IsByteOrderMark(uc32 c) {
238 // The Unicode value U+FFFE is guaranteed never to be assigned as a
239 // Unicode character; this implies that in a Unicode context the
240 // 0xFF, 0xFE byte pattern can only be interpreted as the U+FEFF
241 // character expressed in little-endian byte order (since it could
242 // not be a U+FFFE character expressed in big-endian byte
243 // order). Nevertheless, we check for it to be compatible with
244 // Spidermonkey.
245 return c == 0xFEFF || c == 0xFFFE;
246 }
247
248
237 void Scanner::SkipWhiteSpace(bool initial) { 249 void Scanner::SkipWhiteSpace(bool initial) {
238 has_line_terminator_before_next_ = initial; 250 has_line_terminator_before_next_ = initial;
239 251
240 while (true) { 252 while (true) {
241 while (kIsWhiteSpace.get(c0_)) { 253 // We treat byte-order marks (BOMs) as whitespace for better
254 // compatibility with Spidermonkey and other JavaScript engines.
255 while (kIsWhiteSpace.get(c0_) || IsByteOrderMark(c0_)) {
242 // IsWhiteSpace() includes line terminators! 256 // IsWhiteSpace() includes line terminators!
243 if (kIsLineTerminator.get(c0_)) 257 if (kIsLineTerminator.get(c0_))
244 // Ignore line terminators, but remember them. This is necessary 258 // Ignore line terminators, but remember them. This is necessary
245 // for automatic semicolon insertion. 259 // for automatic semicolon insertion.
246 has_line_terminator_before_next_ = true; 260 has_line_terminator_before_next_ = true;
247 Advance(); 261 Advance();
248 } 262 }
249 263
250 // If there is an HTML comment end '-->' at the beginning of a 264 // If there is an HTML comment end '-->' at the beginning of a
251 // line (with only whitespace in front of it), we treat the rest 265 // line (with only whitespace in front of it), we treat the rest
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 StartLiteral(); 831 StartLiteral();
818 while (kIsIdentifierPart.get(c0_)) 832 while (kIsIdentifierPart.get(c0_))
819 AddCharAdvance(); 833 AddCharAdvance();
820 TerminateLiteral(); 834 TerminateLiteral();
821 835
822 next_.location.end_pos = source_pos() - 1; 836 next_.location.end_pos = source_pos() - 1;
823 return true; 837 return true;
824 } 838 }
825 839
826 } } // namespace v8::internal 840 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | src/stub-cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698