| 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 RUNTIME_VM_SCANNER_H_ | 9 #ifndef RUNTIME_VM_SCANNER_H_ |
| 10 #define RUNTIME_VM_SCANNER_H_ | 10 #define RUNTIME_VM_SCANNER_H_ |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 static void InitOnce(); | 82 static void InitOnce(); |
| 83 | 83 |
| 84 // Return true if str is an identifier. | 84 // Return true if str is an identifier. |
| 85 bool IsIdent(const String& str); | 85 bool IsIdent(const String& str); |
| 86 | 86 |
| 87 // Does the token stream contain a valid integer literal. | 87 // Does the token stream contain a valid integer literal. |
| 88 static bool IsValidInteger(const String& str, | 88 static bool IsValidInteger(const String& str, |
| 89 bool* is_positive, | 89 bool* is_positive, |
| 90 const String** value); | 90 const String** value); |
| 91 | 91 |
| 92 static bool IsIdentStartChar(int32_t c); |
| 93 static bool IsIdentChar(int32_t c); |
| 94 |
| 92 private: | 95 private: |
| 93 friend class ScanContext; | 96 friend class ScanContext; |
| 94 | 97 |
| 95 static const int kNumLowercaseChars = 26; | 98 static const int kNumLowercaseChars = 26; |
| 96 | 99 |
| 97 struct KeywordTable { | 100 struct KeywordTable { |
| 98 Token::Kind kind; | 101 Token::Kind kind; |
| 99 const char* keyword_chars; | 102 const char* keyword_chars; |
| 100 int keyword_len; | 103 int keyword_len; |
| 101 const String* keyword_symbol; | 104 const String* keyword_symbol; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 119 int32_t LookaheadChar(int how_many); | 122 int32_t LookaheadChar(int how_many); |
| 120 | 123 |
| 121 void ErrorMsg(const char* msg); | 124 void ErrorMsg(const char* msg); |
| 122 | 125 |
| 123 // These functions return true if the given character is a letter, | 126 // These functions return true if the given character is a letter, |
| 124 // a decimal digit, a hexadecimal digit, etc. | 127 // a decimal digit, a hexadecimal digit, etc. |
| 125 static bool IsLetter(int32_t c); | 128 static bool IsLetter(int32_t c); |
| 126 static bool IsDecimalDigit(int32_t c); | 129 static bool IsDecimalDigit(int32_t c); |
| 127 static bool IsNumberStart(int32_t); | 130 static bool IsNumberStart(int32_t); |
| 128 static bool IsHexDigit(int32_t c); | 131 static bool IsHexDigit(int32_t c); |
| 129 static bool IsIdentStartChar(int32_t c); | |
| 130 static bool IsIdentChar(int32_t c); | |
| 131 | 132 |
| 132 // Skips up to next non-whitespace character. | 133 // Skips up to next non-whitespace character. |
| 133 void ConsumeWhiteSpace(); | 134 void ConsumeWhiteSpace(); |
| 134 | 135 |
| 135 // Skips characters up to end of line. | 136 // Skips characters up to end of line. |
| 136 void ConsumeLineComment(); | 137 void ConsumeLineComment(); |
| 137 | 138 |
| 138 // Skips characters up to matching '*/'. | 139 // Skips characters up to matching '*/'. |
| 139 void ConsumeBlockComment(); | 140 void ConsumeBlockComment(); |
| 140 | 141 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 Zone* zone_; | 210 Zone* zone_; |
| 210 | 211 |
| 211 static KeywordTable keywords_[Token::kNumKeywords]; | 212 static KeywordTable keywords_[Token::kNumKeywords]; |
| 212 static int keywords_char_offset_[kNumLowercaseChars]; | 213 static int keywords_char_offset_[kNumLowercaseChars]; |
| 213 }; | 214 }; |
| 214 | 215 |
| 215 | 216 |
| 216 } // namespace dart | 217 } // namespace dart |
| 217 | 218 |
| 218 #endif // RUNTIME_VM_SCANNER_H_ | 219 #endif // RUNTIME_VM_SCANNER_H_ |
| OLD | NEW |