Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Side by Side Diff: runtime/vm/scanner.h

Issue 149643007: Small cleanup: move all library private key code to Library class (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 26 matching lines...) Expand all
37 struct TokenDescriptor { 37 struct TokenDescriptor {
38 Token::Kind kind; 38 Token::Kind kind;
39 int offset; // Offset in source string. 39 int offset; // Offset in source string.
40 SourcePosition position; // Text position in source. 40 SourcePosition position; // Text position in source.
41 const String* literal; // Identifier, number or string literal. 41 const String* literal; // Identifier, number or string literal.
42 }; 42 };
43 43
44 // Dummy token index reflecting an unknown source position. 44 // Dummy token index reflecting an unknown source position.
45 static const intptr_t kNoSourcePos = 0; 45 static const intptr_t kNoSourcePos = 0;
46 46
47 // Character used to indicate a private identifier.
48 static const char kPrivateIdentifierStart = '_';
49
50 // Character used to separate the private identifier from the key.
51 static const char kPrivateKeySeparator = '@';
52
53 typedef ZoneGrowableArray<TokenDescriptor> GrowableTokenStream; 47 typedef ZoneGrowableArray<TokenDescriptor> GrowableTokenStream;
54 48
55 // Initializes scanner to scan string source. 49 // Initializes scanner to scan string source.
56 Scanner(const String& source, const String& private_key); 50 Scanner(const String& source, const String& private_key);
57 ~Scanner(); 51 ~Scanner();
58 52
59 // Scans one token at a time. 53 // Scans one token at a time.
60 void Scan(); 54 void Scan();
61 55
62 // Scans to specified token position. 56 // Scans to specified token position.
(...skipping 10 matching lines...) Expand all
73 // Was there a line break before the current token? 67 // Was there a line break before the current token?
74 bool NewlineBeforeToken() const { return newline_seen_; } 68 bool NewlineBeforeToken() const { return newline_seen_; }
75 69
76 // Source code line number and column of current token. 70 // Source code line number and column of current token.
77 const SourcePosition& CurrentPosition() const { 71 const SourcePosition& CurrentPosition() const {
78 return current_token_.position; 72 return current_token_.position;
79 } 73 }
80 74
81 static void InitOnce(); 75 static void InitOnce();
82 76
83 // Allocated a private key which is used for name mangling.
84 static RawString* AllocatePrivateKey(const Library& library);
85
86 // Return true if str is an identifier. 77 // Return true if str is an identifier.
87 static bool IsIdent(const String& str); 78 static bool IsIdent(const String& str);
88 79
89 // Does the token stream contain a valid literal. This is used to implement 80 // Does the token stream contain a valid literal. This is used to implement
90 // the Dart methods int.parse and double.parse. 81 // the Dart methods int.parse and double.parse.
91 static bool IsValidLiteral(const Scanner::GrowableTokenStream& tokens, 82 static bool IsValidLiteral(const Scanner::GrowableTokenStream& tokens,
92 Token::Kind literal_kind, 83 Token::Kind literal_kind,
93 bool* is_positive, 84 bool* is_positive,
94 const String** value); 85 const String** value);
95 86
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 205
215 SourcePosition c0_pos_; // Source position of lookahead character c0_. 206 SourcePosition c0_pos_; // Source position of lookahead character c0_.
216 207
217 static KeywordTable keywords_[Token::numKeywords]; 208 static KeywordTable keywords_[Token::numKeywords];
218 }; 209 };
219 210
220 211
221 } // namespace dart 212 } // namespace dart
222 213
223 #endif // VM_SCANNER_H_ 214 #endif // VM_SCANNER_H_
OLDNEW
« runtime/vm/object.cc ('K') | « runtime/vm/object.cc ('k') | runtime/vm/scanner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698