OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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.loader; | 5 library yaml.loader; |
6 | 6 |
7 import 'package:charcode/ascii.dart'; | 7 import 'package:charcode/ascii.dart'; |
8 import 'package:source_span/source_span.dart'; | 8 import 'package:source_span/source_span.dart'; |
9 | 9 |
10 import 'equality.dart'; | 10 import 'equality.dart'; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 var document = _loadDocument(event); | 56 var document = _loadDocument(event); |
57 _span = _span.expand(document.span); | 57 _span = _span.expand(document.span); |
58 _aliases.clear(); | 58 _aliases.clear(); |
59 return document; | 59 return document; |
60 } | 60 } |
61 | 61 |
62 /// Composes a document object. | 62 /// Composes a document object. |
63 YamlDocument _loadDocument(DocumentStartEvent firstEvent) { | 63 YamlDocument _loadDocument(DocumentStartEvent firstEvent) { |
64 var contents = _loadNode(_parser.parse()); | 64 var contents = _loadNode(_parser.parse()); |
65 | 65 |
66 var lastEvent = _parser.parse(); | 66 var lastEvent = _parser.parse() as DocumentEndEvent; |
67 assert(lastEvent.type == EventType.DOCUMENT_END); | 67 assert(lastEvent.type == EventType.DOCUMENT_END); |
68 | 68 |
69 return new YamlDocument.internal( | 69 return new YamlDocument.internal( |
70 contents, | 70 contents, |
71 firstEvent.span.expand(lastEvent.span), | 71 firstEvent.span.expand(lastEvent.span), |
72 firstEvent.versionDirective, | 72 firstEvent.versionDirective, |
73 firstEvent.tagDirectives, | 73 firstEvent.tagDirectives, |
74 startImplicit: firstEvent.isImplicit, | 74 startImplicit: firstEvent.isImplicit, |
75 endImplicit: lastEvent.isImplicit); | 75 endImplicit: lastEvent.isImplicit); |
76 } | 76 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 return node; | 120 return node; |
121 } | 121 } |
122 | 122 |
123 /// Composes a sequence node. | 123 /// Composes a sequence node. |
124 YamlNode _loadSequence(SequenceStartEvent firstEvent) { | 124 YamlNode _loadSequence(SequenceStartEvent firstEvent) { |
125 if (firstEvent.tag != "!" && firstEvent.tag != null && | 125 if (firstEvent.tag != "!" && firstEvent.tag != null && |
126 firstEvent.tag != "tag:yaml.org,2002:seq") { | 126 firstEvent.tag != "tag:yaml.org,2002:seq") { |
127 throw new YamlException("Invalid tag for sequence.", firstEvent.span); | 127 throw new YamlException("Invalid tag for sequence.", firstEvent.span); |
128 } | 128 } |
129 | 129 |
130 var children = []; | 130 var children = <YamlNode>[]; |
131 var node = new YamlList.internal( | 131 var node = new YamlList.internal( |
132 children, firstEvent.span, firstEvent.style); | 132 children, firstEvent.span, firstEvent.style); |
133 _registerAnchor(firstEvent.anchor, node); | 133 _registerAnchor(firstEvent.anchor, node); |
134 | 134 |
135 var event = _parser.parse(); | 135 var event = _parser.parse(); |
136 while (event.type != EventType.SEQUENCE_END) { | 136 while (event.type != EventType.SEQUENCE_END) { |
137 children.add(_loadNode(event)); | 137 children.add(_loadNode(event)); |
138 event = _parser.parse(); | 138 event = _parser.parse(); |
139 } | 139 } |
140 | 140 |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 case ".nan": | 350 case ".nan": |
351 case ".NaN": | 351 case ".NaN": |
352 case ".NAN": | 352 case ".NAN": |
353 return double.NAN; | 353 return double.NAN; |
354 } | 354 } |
355 } | 355 } |
356 | 356 |
357 return null; | 357 return null; |
358 } | 358 } |
359 } | 359 } |
OLD | NEW |