| 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_descriptor.h" |
| 14 | 15 |
| 15 namespace dart { | 16 namespace dart { |
| 16 | 17 |
| 17 // Forward declarations. | 18 // Forward declarations. |
| 18 class Array; | 19 class Array; |
| 19 class Library; | 20 class Library; |
| 20 class RawString; | 21 class RawString; |
| 21 class ScanContext; | 22 class ScanContext; |
| 22 class String; | 23 class String; |
| 23 | 24 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 48 | 49 |
| 49 // Initializes scanner to scan string source. | 50 // Initializes scanner to scan string source. |
| 50 Scanner(const String& source, const String& private_key); | 51 Scanner(const String& source, const String& private_key); |
| 51 ~Scanner(); | 52 ~Scanner(); |
| 52 | 53 |
| 53 // Scans one token at a time. | 54 // Scans one token at a time. |
| 54 void Scan(); | 55 void Scan(); |
| 55 | 56 |
| 56 // Scans to specified token position. | 57 // Scans to specified token position. |
| 57 // Use CurrentPosition() to extract position. | 58 // Use CurrentPosition() to extract position. |
| 58 void ScanTo(intptr_t token_index); | 59 void ScanTo(dart::TokenDescriptor token_index); |
| 59 | 60 |
| 60 // Scans entire source and returns a stream of tokens. | 61 // Scans entire source and returns a stream of tokens. |
| 61 // Should be called only once. | 62 // Should be called only once. |
| 62 const GrowableTokenStream& GetStream(); | 63 const GrowableTokenStream& GetStream(); |
| 63 | 64 |
| 64 // Info about most recently recognized token. | 65 // Info about most recently recognized token. |
| 65 const TokenDescriptor& current_token() const { return current_token_; } | 66 const TokenDescriptor& current_token() const { return current_token_; } |
| 66 | 67 |
| 67 // Was there a line break before the current token? | 68 // Was there a line break before the current token? |
| 68 bool NewlineBeforeToken() const { return newline_seen_; } | 69 bool NewlineBeforeToken() const { return newline_seen_; } |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 Zone* zone_; | 212 Zone* zone_; |
| 212 | 213 |
| 213 static KeywordTable keywords_[Token::kNumKeywords]; | 214 static KeywordTable keywords_[Token::kNumKeywords]; |
| 214 static int keywords_char_offset_[kNumLowercaseChars]; | 215 static int keywords_char_offset_[kNumLowercaseChars]; |
| 215 }; | 216 }; |
| 216 | 217 |
| 217 | 218 |
| 218 } // namespace dart | 219 } // namespace dart |
| 219 | 220 |
| 220 #endif // VM_SCANNER_H_ | 221 #endif // VM_SCANNER_H_ |
| OLD | NEW |