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

Side by Side Diff: utils/pub/yaml/parser.dart

Issue 10444016: Re-enable Yaml tests on dart2js and dartc. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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 | « no previous file | utils/tests/pub/pub.status » ('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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 /** 5 /**
6 * Translates a string of characters into a YAML serialization tree. 6 * Translates a string of characters into a YAML serialization tree.
7 * 7 *
8 * This parser is designed to closely follow the spec. All productions in the 8 * This parser is designed to closely follow the spec. All productions in the
9 * spec are numbered, and the corresponding methods in the parser have the same 9 * spec are numbered, and the corresponding methods in the parser have the same
10 * numbers. This is certainly not the most efficient way of parsing YAML, but it 10 * numbers. This is certainly not the most efficient way of parsing YAML, but it
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 */ 241 */
242 List oneOrMore(consumer()) { 242 List oneOrMore(consumer()) {
243 var first = consumer(); 243 var first = consumer();
244 if (!truth(first)) return null; 244 if (!truth(first)) return null;
245 var out = [first]; 245 var out = [first];
246 while (true) { 246 while (true) {
247 var el = consumer(); 247 var el = consumer();
248 if (!truth(el)) return out; 248 if (!truth(el)) return out;
249 out.add(el); 249 out.add(el);
250 } 250 }
251 return null; // unreachable
Bob Nystrom 2012/05/24 22:36:50 "Unreachable."
251 } 252 }
252 253
253 /** 254 /**
254 * Calls [consumer] until it returns a falsey value. Returns a list of all 255 * Calls [consumer] until it returns a falsey value. Returns a list of all
255 * truthy return values of [consumer], or the empty list if it didn't consume 256 * truthy return values of [consumer], or the empty list if it didn't consume
256 * anything. 257 * anything.
257 * 258 *
258 * Conceptually, repeats a production any number of times. 259 * Conceptually, repeats a production any number of times.
259 */ 260 */
260 List zeroOrMore(consumer()) { 261 List zeroOrMore(consumer()) {
261 var out = []; 262 var out = [];
262 var oldPos = pos; 263 var oldPos = pos;
263 while (true) { 264 while (true) {
264 var el = consumer(); 265 var el = consumer();
265 if (!truth(el) || oldPos == pos) return out; 266 if (!truth(el) || oldPos == pos) return out;
266 oldPos = pos; 267 oldPos = pos;
267 out.add(el); 268 out.add(el);
268 } 269 }
270 return null; // unreachable
269 } 271 }
270 272
271 /** 273 /**
272 * Just calls [consumer] and returns its result. Used to make it explicit that 274 * Just calls [consumer] and returns its result. Used to make it explicit that
273 * a production is intended to be optional. 275 * a production is intended to be optional.
274 */ 276 */
275 zeroOrOne(consumer()) => consumer(); 277 zeroOrOne(consumer()) => consumer();
276 278
277 /** 279 /**
278 * Calls each function in [consumers] until one returns a truthy value, then 280 * Calls each function in [consumers] until one returns a truthy value, then
(...skipping 1552 matching lines...) Expand 10 before | Expand all | Expand 10 after
1831 s_l_comments(); 1833 s_l_comments();
1832 return doc; 1834 return doc;
1833 } 1835 }
1834 1836
1835 // 209 1837 // 209
1836 _Node l_directiveDocument() { 1838 _Node l_directiveDocument() {
1837 if (!truth(oneOrMore(l_directive))) return null; 1839 if (!truth(oneOrMore(l_directive))) return null;
1838 var doc = l_explicitDocument(); 1840 var doc = l_explicitDocument();
1839 if (doc != null) return doc; 1841 if (doc != null) return doc;
1840 parseFailed(); 1842 parseFailed();
1843 return null; // unreachable
1841 } 1844 }
1842 1845
1843 // 210 1846 // 210
1844 _Node l_anyDocument() => 1847 _Node l_anyDocument() =>
1845 or([l_directiveDocument, l_explicitDocument, l_bareDocument]); 1848 or([l_directiveDocument, l_explicitDocument, l_bareDocument]);
1846 1849
1847 // 211 1850 // 211
1848 List<_Node> l_yamlStream() { 1851 List<_Node> l_yamlStream() {
1849 var docs = []; 1852 var docs = [];
1850 zeroOrMore(l_documentPrefix); 1853 zeroOrMore(l_documentPrefix);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1891 1894
1892 /** The information in the header for a block scalar. */ 1895 /** The information in the header for a block scalar. */
1893 class _BlockHeader { 1896 class _BlockHeader {
1894 final int additionalIndent; 1897 final int additionalIndent;
1895 final int chomping; 1898 final int chomping;
1896 1899
1897 _BlockHeader(this.additionalIndent, this.chomping); 1900 _BlockHeader(this.additionalIndent, this.chomping);
1898 1901
1899 bool get autoDetectIndent() => additionalIndent == null; 1902 bool get autoDetectIndent() => additionalIndent == null;
1900 } 1903 }
OLDNEW
« no previous file with comments | « no previous file | utils/tests/pub/pub.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698