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

Unified Diff: utils/pub/yaml/composer.dart

Issue 10377186: Support a much larger subset of YAML. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: New chunks I guess 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | utils/pub/yaml/parser.dart » ('j') | utils/pub/yaml/parser.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/pub/yaml/composer.dart
diff --git a/utils/pub/yaml/composer.dart b/utils/pub/yaml/composer.dart
index ada81267d8c453120cd7f45035b72085b8656d54..397bb61bf04071c630b936dabd790d43b3ed2c95 100644
--- a/utils/pub/yaml/composer.dart
+++ b/utils/pub/yaml/composer.dart
@@ -152,14 +152,18 @@ class _Composer extends _Visitor {
"^[-+]?(\.[0-9]+|[0-9]+(\.[0-9]*)?)([eE][-+]?[0-9]+)?\$").
firstMatch(content);
if (match != null) {
+ // YAML allows floats of the form "0.", but Dart does not. Fix up those
+ // floats by removing the trailing dot.
+ var matchStr = match.group(0).replaceAll(new RegExp(@"\.$"), "");
return new _ScalarNode(_Tag.yaml("float"),
- value: Math.parseDouble(match.group(0)));
+ value: Math.parseDouble(matchStr));
}
match = const RegExp("^([+-]?)\.(inf|Inf|INF)\$").firstMatch(content);
if (match != null) {
+ var infStr = match.group(1) == "-" ? "-Infinity" : "Infinity";
Bob Nystrom 2012/05/18 21:06:30 wflly shrt nm. How about "infinity"?
nweiz 2012/05/18 21:47:04 Done.
return new _ScalarNode(_Tag.yaml("float"),
- value: Math.parseDouble("${match.group(1)}Infinity"));
+ value: Math.parseDouble(infStr));
}
match = const RegExp("^\.(nan|NaN|NAN)\$").firstMatch(content);
« no previous file with comments | « no previous file | utils/pub/yaml/parser.dart » ('j') | utils/pub/yaml/parser.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698