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

Side by Side Diff: lib/yaml.dart

Issue 1329763002: Don't use regular expressions in Loader. (Closed) Base URL: git@github.com:dart-lang/yaml@master
Patch Set: Code review changes Created 5 years, 3 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
« no previous file with comments | « lib/src/yaml_node_wrapper.dart ('k') | pubspec.yaml » ('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 library yaml; 5 library yaml;
6 6
7 import 'src/loader.dart'; 7 import 'src/loader.dart';
8 import 'src/style.dart'; 8 import 'src/style.dart';
9 import 'src/yaml_document.dart'; 9 import 'src/yaml_document.dart';
10 import 'src/yaml_exception.dart'; 10 import 'src/yaml_exception.dart';
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 /// Loads a single document from a YAML string as a [YamlDocument]. 46 /// Loads a single document from a YAML string as a [YamlDocument].
47 /// 47 ///
48 /// This is just like [loadYaml], except that where [loadYaml] would return a 48 /// This is just like [loadYaml], except that where [loadYaml] would return a
49 /// normal Dart value this returns a [YamlDocument] instead. This allows the 49 /// normal Dart value this returns a [YamlDocument] instead. This allows the
50 /// caller to access document metadata. 50 /// caller to access document metadata.
51 YamlDocument loadYamlDocument(String yaml, {sourceUrl}) { 51 YamlDocument loadYamlDocument(String yaml, {sourceUrl}) {
52 var loader = new Loader(yaml, sourceUrl: sourceUrl); 52 var loader = new Loader(yaml, sourceUrl: sourceUrl);
53 var document = loader.load(); 53 var document = loader.load();
54 if (document == null) { 54 if (document == null) {
55 return new YamlDocument.internal( 55 return new YamlDocument.internal(
56 new YamlScalar.internal(null, loader.span, ScalarStyle.ANY), 56 new YamlScalar.internalWithSpan(null, loader.span),
57 loader.span, null, const []); 57 loader.span, null, const []);
58 } 58 }
59 59
60 var nextDocument = loader.load(); 60 var nextDocument = loader.load();
61 if (nextDocument != null) { 61 if (nextDocument != null) {
62 throw new YamlException("Only expected one document.", nextDocument.span); 62 throw new YamlException("Only expected one document.", nextDocument.span);
63 } 63 }
64 64
65 return document; 65 return document;
66 } 66 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 103
104 var documents = []; 104 var documents = [];
105 var document = loader.load(); 105 var document = loader.load();
106 while (document != null) { 106 while (document != null) {
107 documents.add(document); 107 documents.add(document);
108 document = loader.load(); 108 document = loader.load();
109 } 109 }
110 110
111 return documents; 111 return documents;
112 } 112 }
OLDNEW
« no previous file with comments | « lib/src/yaml_node_wrapper.dart ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698