| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // Scanner class for the Dart language. The scanner reads source text | 5 // Scanner class for the Dart language. The scanner reads source text |
| 6 // and produces a stream of tokens which is used by the parser. | 6 // and produces a stream of tokens which is used by the parser. |
| 7 // | 7 // |
| 8 | 8 |
| 9 #ifndef VM_SCANNER_H_ | 9 #ifndef VM_SCANNER_H_ |
| 10 #define VM_SCANNER_H_ | 10 #define VM_SCANNER_H_ |
| 11 | 11 |
| 12 #include "vm/growable_array.h" | 12 #include "vm/growable_array.h" |
| 13 #include "vm/token.h" | 13 #include "vm/token.h" |
| 14 #include "vm/token_position.h" | |
| 15 | 14 |
| 16 namespace dart { | 15 namespace dart { |
| 17 | 16 |
| 18 // Forward declarations. | 17 // Forward declarations. |
| 19 class Array; | 18 class Array; |
| 20 class Library; | 19 class Library; |
| 21 class RawString; | 20 class RawString; |
| 22 class ScanContext; | 21 class ScanContext; |
| 23 class String; | 22 class String; |
| 24 | 23 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 48 typedef ZoneGrowableArray<TokenDescriptor> GrowableTokenStream; | 47 typedef ZoneGrowableArray<TokenDescriptor> GrowableTokenStream; |
| 49 | 48 |
| 50 // Initializes scanner to scan string source. | 49 // Initializes scanner to scan string source. |
| 51 Scanner(const String& source, const String& private_key); | 50 Scanner(const String& source, const String& private_key); |
| 52 ~Scanner(); | 51 ~Scanner(); |
| 53 | 52 |
| 54 // Scans one token at a time. | 53 // Scans one token at a time. |
| 55 void Scan(); | 54 void Scan(); |
| 56 | 55 |
| 57 // Scans to specified token position. | 56 // Scans to specified token position. |
| 58 // Use CurrentPosition() to extract position. | 57 // Use CurrentPosition() to extract line and column number. |
| 59 void ScanTo(TokenPosition token_index); | 58 void ScanTo(intptr_t token_index); |
| 60 | 59 |
| 61 // Scans entire source and returns a stream of tokens. | 60 // Scans entire source and returns a stream of tokens. |
| 62 // Should be called only once. | 61 // Should be called only once. |
| 63 const GrowableTokenStream& GetStream(); | 62 const GrowableTokenStream& GetStream(); |
| 64 | 63 |
| 65 // Info about most recently recognized token. | 64 // Info about most recently recognized token. |
| 66 const TokenDescriptor& current_token() const { return current_token_; } | 65 const TokenDescriptor& current_token() const { return current_token_; } |
| 67 | 66 |
| 68 // Was there a line break before the current token? | 67 // Was there a line break before the current token? |
| 69 bool NewlineBeforeToken() const { return newline_seen_; } | 68 bool NewlineBeforeToken() const { return newline_seen_; } |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 Zone* zone_; | 213 Zone* zone_; |
| 215 | 214 |
| 216 static KeywordTable keywords_[Token::kNumKeywords]; | 215 static KeywordTable keywords_[Token::kNumKeywords]; |
| 217 static int keywords_char_offset_[kNumLowercaseChars]; | 216 static int keywords_char_offset_[kNumLowercaseChars]; |
| 218 }; | 217 }; |
| 219 | 218 |
| 220 | 219 |
| 221 } // namespace dart | 220 } // namespace dart |
| 222 | 221 |
| 223 #endif // VM_SCANNER_H_ | 222 #endif // VM_SCANNER_H_ |
| OLD | NEW |