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

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

Issue 10981031: Convert raw strings in pub (and apidoc) to new syntax. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Respond to review. Created 8 years, 2 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/pub/version.dart ('k') | utils/tests/pub/pub_install_git_test.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) 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 * Takes a parsed YAML document (what the spec calls the "serialization tree") 6 * Takes a parsed YAML document (what the spec calls the "serialization tree")
7 * and resolves aliases, resolves tags, and parses scalars to produce the 7 * and resolves aliases, resolves tags, and parses scalars to produce the
8 * "representation graph". 8 * "representation graph".
9 */ 9 */
10 class _Composer extends _Visitor { 10 class _Composer extends _Visitor {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } 147 }
148 148
149 /** Parses a floating-point scalar. */ 149 /** Parses a floating-point scalar. */
150 _ScalarNode parseFloat(String content) { 150 _ScalarNode parseFloat(String content) {
151 var match = const RegExp( 151 var match = const RegExp(
152 "^[-+]?(\.[0-9]+|[0-9]+(\.[0-9]*)?)([eE][-+]?[0-9]+)?\$"). 152 "^[-+]?(\.[0-9]+|[0-9]+(\.[0-9]*)?)([eE][-+]?[0-9]+)?\$").
153 firstMatch(content); 153 firstMatch(content);
154 if (match != null) { 154 if (match != null) {
155 // YAML allows floats of the form "0.", but Dart does not. Fix up those 155 // YAML allows floats of the form "0.", but Dart does not. Fix up those
156 // floats by removing the trailing dot. 156 // floats by removing the trailing dot.
157 var matchStr = match.group(0).replaceAll(new RegExp(@"\.$"), ""); 157 var matchStr = match.group(0).replaceAll(new RegExp(r"\.$"), "");
158 return new _ScalarNode(_Tag.yaml("float"), 158 return new _ScalarNode(_Tag.yaml("float"),
159 value: Math.parseDouble(matchStr)); 159 value: Math.parseDouble(matchStr));
160 } 160 }
161 161
162 match = const RegExp("^([+-]?)\.(inf|Inf|INF)\$").firstMatch(content); 162 match = const RegExp("^([+-]?)\.(inf|Inf|INF)\$").firstMatch(content);
163 if (match != null) { 163 if (match != null) {
164 var infinityStr = match.group(1) == "-" ? "-Infinity" : "Infinity"; 164 var infinityStr = match.group(1) == "-" ? "-Infinity" : "Infinity";
165 return new _ScalarNode(_Tag.yaml("float"), 165 return new _ScalarNode(_Tag.yaml("float"),
166 value: Math.parseDouble(infinityStr)); 166 value: Math.parseDouble(infinityStr));
167 } 167 }
168 168
169 match = const RegExp("^\.(nan|NaN|NAN)\$").firstMatch(content); 169 match = const RegExp("^\.(nan|NaN|NAN)\$").firstMatch(content);
170 if (match != null) { 170 if (match != null) {
171 return new _ScalarNode(_Tag.yaml("float"), 171 return new _ScalarNode(_Tag.yaml("float"),
172 value: Math.parseDouble("NaN")); 172 value: Math.parseDouble("NaN"));
173 } 173 }
174 174
175 return null; 175 return null;
176 } 176 }
177 177
178 /** Parses a string scalar. */ 178 /** Parses a string scalar. */
179 _ScalarNode parseString(String content) => 179 _ScalarNode parseString(String content) =>
180 new _ScalarNode(_Tag.yaml("str"), value: content); 180 new _ScalarNode(_Tag.yaml("str"), value: content);
181 } 181 }
OLDNEW
« no previous file with comments | « utils/pub/version.dart ('k') | utils/tests/pub/pub_install_git_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698