Chromium Code Reviews| 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_ |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 intptr_t* last_token_index); | 74 intptr_t* last_token_index); |
| 75 | 75 |
| 76 // Scans entire source and returns a stream of tokens. | 76 // Scans entire source and returns a stream of tokens. |
| 77 // Should be called only once. | 77 // Should be called only once. |
| 78 const GrowableTokenStream& GetStream(); | 78 const GrowableTokenStream& GetStream(); |
| 79 | 79 |
| 80 // Info about most recently recognized token. | 80 // Info about most recently recognized token. |
| 81 const TokenDescriptor& current_token() const { return current_token_; } | 81 const TokenDescriptor& current_token() const { return current_token_; } |
| 82 | 82 |
| 83 // Was there a line break before the current token? | 83 // Was there a line break before the current token? |
| 84 bool NewlineBeforeToken() const { return newline_seen_; } | 84 bool NewlineBeforeToken() const { return newline_seen_ > 0; } |
| 85 | 85 |
| 86 // Source code line number and column of current token. | 86 // Source code line number and column of current token. |
| 87 const SourcePosition& CurrentPosition() const { | 87 const SourcePosition& CurrentPosition() const { |
| 88 return current_token_.position; | 88 return current_token_.position; |
| 89 } | 89 } |
| 90 | 90 |
| 91 static void InitOnce(); | 91 static void InitOnce(); |
| 92 | 92 |
| 93 // Allocated a private key which is used for name mangling. | 93 // Allocated a private key which is used for name mangling. |
| 94 static RawString* AllocatePrivateKey(const Library& library); | 94 static RawString* AllocatePrivateKey(const Library& library); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 } | 196 } |
| 197 | 197 |
| 198 // Reads a number literal. | 198 // Reads a number literal. |
| 199 void ScanNumber(bool dec_point_seen); | 199 void ScanNumber(bool dec_point_seen); |
| 200 | 200 |
| 201 void ScanScriptTag(); | 201 void ScanScriptTag(); |
| 202 | 202 |
| 203 static void PrintTokens(const GrowableTokenStream& ts); | 203 static void PrintTokens(const GrowableTokenStream& ts); |
| 204 | 204 |
| 205 TokenDescriptor current_token_; // Current token. | 205 TokenDescriptor current_token_; // Current token. |
| 206 TokenDescriptor newline_token_; // Newline token. | |
| 206 const String& source_; // The source text being tokenized. | 207 const String& source_; // The source text being tokenized. |
| 207 intptr_t source_length_; // The length of the source text. | 208 intptr_t source_length_; // The length of the source text. |
| 208 intptr_t lookahead_pos_; // Position of lookahead character | 209 intptr_t lookahead_pos_; // Position of lookahead character |
| 209 // within source_. | 210 // within source_. |
| 210 intptr_t token_start_; // Begin of current token in src_. | 211 intptr_t token_start_; // Begin of current token in src_. |
| 211 int32_t c0_; // Lookahead character. | 212 int32_t c0_; // Lookahead character. |
| 212 bool newline_seen_; // Newline before current token. | 213 intptr_t newline_seen_; // Number of newlines before current token. |
|
hausner
2013/09/18 22:27:47
num_newlines_before_ ?
Michael Lippautz (Google)
2013/09/18 23:59:31
Doesn't apply anymore. Reverted it to being a flag
| |
| 214 intptr_t newline_save_; // Savepoint for newlines in StringLiterals. | |
| 215 intptr_t newline_after_; // Number of newlines after current token. | |
| 213 | 216 |
| 214 // The following fields keep track whether we are scanning a string literal | 217 // The following fields keep track whether we are scanning a string literal |
| 215 // and its interpolated expressions. | 218 // and its interpolated expressions. |
| 216 ScanContext* saved_context_; | 219 ScanContext* saved_context_; |
| 217 int32_t string_delimiter_; | 220 int32_t string_delimiter_; |
| 218 bool string_is_multiline_; | 221 bool string_is_multiline_; |
| 219 int brace_level_; | 222 int brace_level_; |
| 220 | 223 |
| 221 const String& private_key_; | 224 const String& private_key_; |
| 222 | 225 |
| 223 SourcePosition c0_pos_; // Source position of lookahead character c0_. | 226 SourcePosition c0_pos_; // Source position of lookahead character c0_. |
| 224 KeywordTable keywords_[Token::numKeywords]; | 227 KeywordTable keywords_[Token::numKeywords]; |
| 225 Array& keyword_symbol_table_; // Access to keyword symbols in object store. | 228 Array& keyword_symbol_table_; // Access to keyword symbols in object store. |
| 226 }; | 229 }; |
| 227 | 230 |
| 228 | 231 |
| 229 } // namespace dart | 232 } // namespace dart |
| 230 | 233 |
| 231 #endif // VM_SCANNER_H_ | 234 #endif // VM_SCANNER_H_ |
| OLD | NEW |