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

Side by Side Diff: utils/peg/pegparser.dart

Issue 12282038: Remove deprecated string features. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge to head Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « utils/css/tokenkind.dart ('k') | utils/pub/hosted_source.dart » ('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 (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library Peg Parser; 5 library Peg Parser;
6 6
7 /* 7 /*
8 * The following functions are combinators for building Rules. 8 * The following functions are combinators for building Rules.
9 * 9 *
10 * A rule is one of the following 10 * A rule is one of the following
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 * CHAR does not generate a value. 55 * CHAR does not generate a value.
56 */ 56 */
57 _Rule CHAR([characters]) { 57 _Rule CHAR([characters]) {
58 if (characters == null) 58 if (characters == null)
59 return const _AnyCharRule(); 59 return const _AnyCharRule();
60 if (characters is int) 60 if (characters is int)
61 return CHARCODE(characters); 61 return CHARCODE(characters);
62 62
63 // Find the range of character codes and construct an array of flags for codes 63 // Find the range of character codes and construct an array of flags for codes
64 // within the range. 64 // within the range.
65 List<int> codes = characters.charCodes; 65 List<int> codes = characters.codeUnits;
66 codes.sort((a, b) => a < b ? -1 : a > b ? 1 : 0); 66 codes.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
67 int lo = codes[0]; 67 int lo = codes[0];
68 int hi = codes[codes.length - 1]; 68 int hi = codes[codes.length - 1];
69 if (lo == hi) 69 if (lo == hi)
70 return CHARCODE(lo); 70 return CHARCODE(lo);
71 int len = hi - lo + 1; 71 int len = hi - lo + 1;
72 var flags = new List<bool>.fixedLength(len); 72 var flags = new List<bool>.fixedLength(len);
73 for (int i = 0; i < len; ++i) 73 for (int i = 0; i < len; ++i)
74 flags[i] = false; 74 flags[i] = false;
75 for (int code in codes) 75 for (int code in codes)
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 toString() => 'ERROR($message)'; 445 toString() => 'ERROR($message)';
446 } 446 }
447 447
448 class _CharCodeRule extends _Rule { 448 class _CharCodeRule extends _Rule {
449 Function _predicate; 449 Function _predicate;
450 var _name; 450 var _name;
451 _CharCodeRule(this._predicate, this._name); 451 _CharCodeRule(this._predicate, this._name);
452 _match(_ParserState state, int pos) { 452 _match(_ParserState state, int pos) {
453 if (pos == state._end) 453 if (pos == state._end)
454 return null; 454 return null;
455 int code = state._text.charCodeAt(pos); 455 int code = state._text.codeUnitAt(pos);
456 if (_predicate(code)) 456 if (_predicate(code))
457 return [pos + 1, null]; 457 return [pos + 1, null];
458 return null; 458 return null;
459 } 459 }
460 460
461 toString() => _name == null ? 'CHARCODE($_predicate)' : 'CHARCODE($_name)'; 461 toString() => _name == null ? 'CHARCODE($_predicate)' : 'CHARCODE($_name)';
462 } 462 }
463 463
464 class _AnyCharRule extends _Rule { 464 class _AnyCharRule extends _Rule {
465 const _AnyCharRule(); 465 const _AnyCharRule();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 final String _string; 504 final String _string;
505 int _len; 505 int _len;
506 _StringRule(this._string) { 506 _StringRule(this._string) {
507 _len = _string.length; 507 _len = _string.length;
508 } 508 }
509 509
510 _match(_ParserState state, int pos) { 510 _match(_ParserState state, int pos) {
511 if (pos + _len > state._end) 511 if (pos + _len > state._end)
512 return null; 512 return null;
513 for (int i = 0; i < _len; i++) { 513 for (int i = 0; i < _len; i++) {
514 if (state._text.charCodeAt(pos + i) != _string.charCodeAt(i)) 514 if (state._text.codeUnitAt(pos + i) != _string.codeUnitAt(i))
515 return null; 515 return null;
516 } 516 }
517 return [pos + _len, null]; 517 return [pos + _len, null];
518 } 518 }
519 519
520 //get defaultValue => _string; 520 //get defaultValue => _string;
521 521
522 toString() => '"$_string"'; 522 toString() => '"$_string"';
523 523
524 description() => "'$_string'"; 524 description() => "'$_string'";
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 add(s); 849 add(s);
850 add(t); 850 add(t);
851 add(u); 851 add(u);
852 add(v); 852 add(v);
853 add(w); 853 add(w);
854 add(x); 854 add(x);
855 add(y); 855 add(y);
856 add(z); 856 add(z);
857 return list; 857 return list;
858 } 858 }
OLDNEW
« no previous file with comments | « utils/css/tokenkind.dart ('k') | utils/pub/hosted_source.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698