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

Unified Diff: runtime/vm/scanner.cc

Issue 11316031: - Move MathNatives from dart:core to dart:math. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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 | « runtime/vm/scanner.h ('k') | runtime/vm/vm.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/scanner.cc
===================================================================
--- runtime/vm/scanner.cc (revision 14972)
+++ runtime/vm/scanner.cc (working copy)
@@ -174,6 +174,36 @@
}
+// This method is used when parsing integers and doubles in Dart code. We
+// are reusing the Scanner's handling of number literals in that situation.
+bool Scanner::IsValidLiteral(const Scanner::GrowableTokenStream& tokens,
+ Token::Kind literal_kind,
+ bool* is_positive,
+ String** value) {
+ if ((tokens.length() == 2) &&
+ (tokens[0].kind == literal_kind) &&
+ (tokens[1].kind == Token::kEOS)) {
+ *is_positive = true;
+ *value = tokens[0].literal;
+ return true;
+ }
+ if ((tokens.length() == 3) &&
+ ((tokens[0].kind == Token::kTIGHTADD) ||
+ (tokens[0].kind == Token::kSUB)) &&
+ (tokens[1].kind == literal_kind) &&
+ (tokens[2].kind == Token::kEOS)) {
+ // Check there is no space between "+/-" and number.
+ if ((tokens[0].offset + 1) != tokens[1].offset) {
+ return false;
+ }
+ *is_positive = tokens[0].kind == Token::kTIGHTADD;
+ *value = tokens[1].literal;
+ return true;
+ }
+ return false;
+}
+
+
void Scanner::ReadChar() {
if (lookahead_pos_ < source_length_) {
if (c0_ == '\n') {
« no previous file with comments | « runtime/vm/scanner.h ('k') | runtime/vm/vm.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698