| OLD | NEW |
| 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 Loading... |
| 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 | PIXELS | DOUBLE |
| 349 // INTEGER = D+ | (("0x" | "0X") H+) | 349 // INTEGER = D+ | (("0x" | "0X") H+) |
| 350 // PIXELS = ((D+ ["." D*]) | ("." D+)) ("px" | "PX") |
| 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 Loading... |
| 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_ == 'p') && (LookaheadChar(1) == 'x')) { |
| 393 ReadChar(); |
| 394 Recognize(Token::kPIXELS); |
| 395 } else if ((c0_ == 'P') && (LookaheadChar(1) == 'X')) { |
| 396 ReadChar(); |
| 397 Recognize(Token::kPIXELS); |
| 391 } | 398 } |
| 392 } | 399 } |
| 393 if (current_token_.kind != Token::kILLEGAL) { | 400 if (current_token_.kind != Token::kILLEGAL) { |
| 394 intptr_t len = lookahead_pos_ - token_start_; | 401 intptr_t len = lookahead_pos_ - token_start_; |
| 395 const String& str = | 402 const String& str = |
| 396 String::ZoneHandle(Z, Symbols::New(T, source_, token_start_, len)); | 403 String::ZoneHandle(Z, Symbols::New(T, source_, token_start_, len)); |
| 397 current_token_.literal = &str; | 404 current_token_.literal = &str; |
| 398 } | 405 } |
| 399 } | 406 } |
| 400 | 407 |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 954 keywords_[i].keyword_symbol = &Symbols::Token(token); | 961 keywords_[i].keyword_symbol = &Symbols::Token(token); |
| 955 | 962 |
| 956 int ch = keywords_[i].keyword_chars[0] - 'a'; | 963 int ch = keywords_[i].keyword_chars[0] - 'a'; |
| 957 if (keywords_char_offset_[ch] == Token::kNumKeywords) { | 964 if (keywords_char_offset_[ch] == Token::kNumKeywords) { |
| 958 keywords_char_offset_[ch] = i; | 965 keywords_char_offset_[ch] = i; |
| 959 } | 966 } |
| 960 } | 967 } |
| 961 } | 968 } |
| 962 | 969 |
| 963 } // namespace dart | 970 } // namespace dart |
| OLD | NEW |