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

Side by Side Diff: runtime/vm/scanner.cc

Issue 2005723004: Fraction class prototype and test (not to be committed). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: work in progress Created 4 years, 5 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
« no previous file with comments | « runtime/vm/raw_object_snapshot.cc ('k') | runtime/vm/snapshot.h » ('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 #include "vm/scanner.h" 5 #include "vm/scanner.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/dart.h" 8 #include "vm/dart.h"
9 #include "vm/flags.h" 9 #include "vm/flags.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 // Private identifiers are mangled on a per library basis. 337 // Private identifiers are mangled on a per library basis.
338 literal = String::SubString(T, source_, ident_pos, ident_length); 338 literal = String::SubString(T, source_, ident_pos, ident_length);
339 literal = Symbols::FromConcat(T, literal, private_key_); 339 literal = Symbols::FromConcat(T, literal, private_key_);
340 } else { 340 } else {
341 literal = Symbols::New(T, source_, ident_pos, ident_length); 341 literal = Symbols::New(T, source_, ident_pos, ident_length);
342 } 342 }
343 current_token_.literal = &literal; 343 current_token_.literal = &literal;
344 } 344 }
345 345
346 346
347 // Parse integer or double number literal of format: 347 // Parse integer, rational, or double number literal of format:
348 // NUMBER = INTEGER | DOUBLE 348 // NUMBER = INTEGER | RATIONAL | DOUBLE
349 // INTEGER = D+ | (("0x" | "0X") H+) 349 // INTEGER = D+ | (("0x" | "0X") H+)
350 // RATIONAL = ((D+ ["." D*]) | ("." D+)) ("r" | "R")
350 // DOUBLE = ((D+ ["." D*]) | ("." D+)) [ EXPONENT ] 351 // DOUBLE = ((D+ ["." D*]) | ("." D+)) [ EXPONENT ]
351 // EXPONENT = ("e" | "E") ["+" | "-"] D+ 352 // EXPONENT = ("e" | "E") ["+" | "-"] D+
352 void Scanner::ScanNumber(bool dec_point_seen) { 353 void Scanner::ScanNumber(bool dec_point_seen) {
353 ASSERT(IsDecimalDigit(c0_)); 354 ASSERT(IsDecimalDigit(c0_));
354 char first_digit = c0_; 355 char first_digit = c0_;
355 356
356 Recognize(dec_point_seen ? Token::kDOUBLE : Token::kINTEGER); 357 Recognize(dec_point_seen ? Token::kDOUBLE : Token::kINTEGER);
357 if (!dec_point_seen && first_digit == '0' && (c0_ == 'x' || c0_ == 'X')) { 358 if (!dec_point_seen && first_digit == '0' && (c0_ == 'x' || c0_ == 'X')) {
358 ReadChar(); 359 ReadChar();
359 if (!IsHexDigit(c0_)) { 360 if (!IsHexDigit(c0_)) {
(...skipping 21 matching lines...) Expand all
381 if ((c0_ == '-') || (c0_ == '+')) { 382 if ((c0_ == '-') || (c0_ == '+')) {
382 ReadChar(); 383 ReadChar();
383 } 384 }
384 if (!IsDecimalDigit(c0_)) { 385 if (!IsDecimalDigit(c0_)) {
385 ErrorMsg("missing exponent digits"); 386 ErrorMsg("missing exponent digits");
386 return; 387 return;
387 } 388 }
388 while (IsDecimalDigit(c0_)) { 389 while (IsDecimalDigit(c0_)) {
389 ReadChar(); 390 ReadChar();
390 } 391 }
392 } else if ((c0_ == 'r') || (c0_ == 'R')) {
393 Recognize(Token::kRATIONAL);
391 } 394 }
392 } 395 }
393 if (current_token_.kind != Token::kILLEGAL) { 396 if (current_token_.kind != Token::kILLEGAL) {
394 intptr_t len = lookahead_pos_ - token_start_; 397 intptr_t len = lookahead_pos_ - token_start_;
395 const String& str = 398 const String& str =
396 String::ZoneHandle(Z, Symbols::New(T, source_, token_start_, len)); 399 String::ZoneHandle(Z, Symbols::New(T, source_, token_start_, len));
397 current_token_.literal = &str; 400 current_token_.literal = &str;
398 } 401 }
399 } 402 }
400 403
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 keywords_[i].keyword_symbol = &Symbols::Token(token); 957 keywords_[i].keyword_symbol = &Symbols::Token(token);
955 958
956 int ch = keywords_[i].keyword_chars[0] - 'a'; 959 int ch = keywords_[i].keyword_chars[0] - 'a';
957 if (keywords_char_offset_[ch] == Token::kNumKeywords) { 960 if (keywords_char_offset_[ch] == Token::kNumKeywords) {
958 keywords_char_offset_[ch] = i; 961 keywords_char_offset_[ch] = i;
959 } 962 }
960 } 963 }
961 } 964 }
962 965
963 } // namespace dart 966 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/raw_object_snapshot.cc ('k') | runtime/vm/snapshot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698