| OLD | NEW |
| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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.codeUnits; | 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>(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) |
| 76 flags[code - lo] = true; | 76 flags[code - lo] = true; |
| 77 | 77 |
| 78 return CHARCODE((code) => code >= lo && code <= hi && flags[code - lo]); | 78 return CHARCODE((code) => code >= lo && code <= hi && flags[code - lo]); |
| 79 } | 79 } |
| 80 | 80 |
| 81 /** | 81 /** |
| 82 * Matches the end of the input. | 82 * Matches the end of the input. |
| (...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 } |
| OLD | NEW |