| 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 | 14 |
| 15 namespace dart { | 15 namespace dart { |
| 16 | 16 |
| 17 // Forward declarations. | 17 // Forward declarations. |
| 18 class Array; | 18 class Array; |
| 19 class Library; | 19 class Library; |
| 20 class RawString; | 20 class RawString; |
| 21 class ScanContext; | 21 class ScanContext; |
| 22 class String; | 22 class String; |
| 23 | 23 |
| 24 // A call to Scan() scans the source one token at at time. | 24 // A call to Scan() scans the source one token at at time. |
| 25 // The scanned token is returned by cur_token(). | 25 // The scanned token is returned by cur_token(). |
| 26 // GetStream() scans the entire source text and returns a stream of tokens. | 26 // GetStream() scans the entire source text and returns a stream of tokens. |
| 27 class Scanner : ValueObject { | 27 class Scanner : ValueObject { |
| 28 public: | 28 public: |
| 29 typedef int32_t (*CharAtFunc)(const String& str, intptr_t index); | 29 typedef uint16_t (*CharAtFunc)(const String& str, intptr_t index); |
| 30 | 30 |
| 31 // SourcePosition describes a text location in user friendly | 31 // SourcePosition describes a text location in user friendly |
| 32 // terms of line number and column. | 32 // terms of line number and column. |
| 33 struct SourcePosition { | 33 struct SourcePosition { |
| 34 int line; | 34 int line; |
| 35 int column; | 35 int column; |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 // TokenDesc defines the kind of a token and its location in | 38 // TokenDesc defines the kind of a token and its location in |
| 39 // the source text. | 39 // the source text. |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 Isolate* isolate_; | 214 Isolate* isolate_; |
| 215 | 215 |
| 216 static KeywordTable keywords_[Token::kNumKeywords]; | 216 static KeywordTable keywords_[Token::kNumKeywords]; |
| 217 static int keywords_char_offset_[kNumLowercaseChars]; | 217 static int keywords_char_offset_[kNumLowercaseChars]; |
| 218 }; | 218 }; |
| 219 | 219 |
| 220 | 220 |
| 221 } // namespace dart | 221 } // namespace dart |
| 222 | 222 |
| 223 #endif // VM_SCANNER_H_ | 223 #endif // VM_SCANNER_H_ |
| OLD | NEW |