Index: runtime/vm/scanner.cc |
=================================================================== |
--- runtime/vm/scanner.cc (revision 14972) |
+++ runtime/vm/scanner.cc (working copy) |
@@ -174,6 +174,36 @@ |
} |
+// TODO(srdjan): Investigate for performance hit; the integer and double parsing |
+// may not be efficient as we need to generate two extra growable arrays. |
siva
2012/11/16 01:34:26
This comment here does not seem to make sense?
Ivan Posva
2012/11/16 19:26:43
Adjusted comment explaining what this method is fo
|
+bool Scanner::IsValidLiteral(const Scanner::GrowableTokenStream& tokens, |
+ Token::Kind literal_kind, |
Mads Ager (google)
2012/11/16 05:46:21
Indentation is slightly off.
Ivan Posva
2012/11/16 19:26:43
Done.
|
+ 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)) && |
Mads Ager (google)
2012/11/16 05:46:21
Indentation sligthly off.
Ivan Posva
2012/11/16 19:26:43
Done.
|
+ (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') { |