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

Side by Side Diff: dart/lib/compiler/implementation/scanner/token.dart

Issue 10876008: Remove most superfluous getter arguments from dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 4 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 final int EOF_TOKEN = 0; 5 final int EOF_TOKEN = 0;
6 6
7 final int KEYWORD_TOKEN = $k; 7 final int KEYWORD_TOKEN = $k;
8 final int IDENTIFIER_TOKEN = $a; 8 final int IDENTIFIER_TOKEN = $a;
9 final int DOUBLE_TOKEN = $d; 9 final int DOUBLE_TOKEN = $d;
10 final int INT_TOKEN = $i; 10 final int INT_TOKEN = $i;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 */ 95 */
96 final int charOffset; 96 final int charOffset;
97 97
98 /** 98 /**
99 * The next token in the token stream. 99 * The next token in the token stream.
100 */ 100 */
101 Token next; 101 Token next;
102 102
103 Token(PrecedenceInfo this.info, int this.charOffset); 103 Token(PrecedenceInfo this.info, int this.charOffset);
104 104
105 get value() => info.value; 105 get value => info.value;
106 106
107 /** 107 /**
108 * Returns the string value for keywords and symbols. For instance 'class' for 108 * Returns the string value for keywords and symbols. For instance 'class' for
109 * the [CLASS] keyword token and '*' for a [Token] based on [STAR_INFO]. For 109 * the [CLASS] keyword token and '*' for a [Token] based on [STAR_INFO]. For
110 * other tokens, such identifiers, strings, numbers, etc, [stringValue] 110 * other tokens, such identifiers, strings, numbers, etc, [stringValue]
111 * returns [:null:]. 111 * returns [:null:].
112 * 112 *
113 * [stringValue] should only be used for testing keywords and symbols. 113 * [stringValue] should only be used for testing keywords and symbols.
114 */ 114 */
115 String get stringValue() => info.value.stringValue; 115 String get stringValue => info.value.stringValue;
116 116
117 /** 117 /**
118 * The kind enum of this token as determined by its [info]. 118 * The kind enum of this token as determined by its [info].
119 */ 119 */
120 int get kind() => info.kind; 120 int get kind => info.kind;
121 121
122 /** 122 /**
123 * The precedence level for this token. 123 * The precedence level for this token.
124 */ 124 */
125 int get precedence() => info.precedence; 125 int get precedence => info.precedence;
126 126
127 /** 127 /**
128 * Returns a textual representation of this token to be used for debugging 128 * Returns a textual representation of this token to be used for debugging
129 * purposes. The resulting string might contain information about the 129 * purposes. The resulting string might contain information about the
130 * structure of the token, for example 'StringToken(foo)' for the identifier 130 * structure of the token, for example 'StringToken(foo)' for the identifier
131 * token 'foo'. Use [slowToString] for the text actually parsed by the token. 131 * token 'foo'. Use [slowToString] for the text actually parsed by the token.
132 */ 132 */
133 String toString() => info.value.toString(); 133 String toString() => info.value.toString();
134 134
135 /** 135 /**
136 * The text parsed by this token. 136 * The text parsed by this token.
137 */ 137 */
138 String slowToString() => toString(); 138 String slowToString() => toString();
139 139
140 /** 140 /**
141 * The number of characters parsed by this token. 141 * The number of characters parsed by this token.
142 */ 142 */
143 int get slowCharCount() => slowToString().length; 143 int get slowCharCount => slowToString().length;
144 } 144 }
145 145
146 /** 146 /**
147 * A keyword token. 147 * A keyword token.
148 */ 148 */
149 class KeywordToken extends Token { 149 class KeywordToken extends Token {
150 final Keyword value; 150 final Keyword value;
151 String get stringValue() => value.syntax; 151 String get stringValue => value.syntax;
152 152
153 KeywordToken(Keyword value, int charOffset) 153 KeywordToken(Keyword value, int charOffset)
154 : this.value = value, super(value.info, charOffset); 154 : this.value = value, super(value.info, charOffset);
155 155
156 String toString() => value.syntax; 156 String toString() => value.syntax;
157 } 157 }
158 158
159 /** 159 /**
160 * A String-valued token. 160 * A String-valued token.
161 */ 161 */
162 class StringToken extends Token { 162 class StringToken extends Token {
163 final SourceString value; 163 final SourceString value;
164 String get stringValue() => value.stringValue; 164 String get stringValue => value.stringValue;
165 165
166 StringToken(PrecedenceInfo info, String value, int charOffset) 166 StringToken(PrecedenceInfo info, String value, int charOffset)
167 : this.fromSource(info, new SourceString(value), charOffset); 167 : this.fromSource(info, new SourceString(value), charOffset);
168 168
169 StringToken.fromSource(PrecedenceInfo info, this.value, int charOffset) 169 StringToken.fromSource(PrecedenceInfo info, this.value, int charOffset)
170 : super(info, charOffset); 170 : super(info, charOffset);
171 171
172 String toString() => "StringToken(${value.slowToString()})"; 172 String toString() => "StringToken(${value.slowToString()})";
173 173
174 String slowToString() => value.slowToString(); 174 String slowToString() => value.slowToString();
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 495
496 final PrecedenceInfo HEXADECIMAL_INFO = 496 final PrecedenceInfo HEXADECIMAL_INFO =
497 const PrecedenceInfo(const SourceString('hexadecimal'), 0, HEXADECIMAL_TOKEN); 497 const PrecedenceInfo(const SourceString('hexadecimal'), 0, HEXADECIMAL_TOKEN);
498 498
499 final PrecedenceInfo COMMENT_INFO = 499 final PrecedenceInfo COMMENT_INFO =
500 const PrecedenceInfo(const SourceString('comment'), 0, COMMENT_TOKEN); 500 const PrecedenceInfo(const SourceString('comment'), 0, COMMENT_TOKEN);
501 501
502 // For reporting lexical errors. 502 // For reporting lexical errors.
503 final PrecedenceInfo ERROR_INFO = 503 final PrecedenceInfo ERROR_INFO =
504 const PrecedenceInfo(const SourceString('?'), 0, UNKNOWN_TOKEN); 504 const PrecedenceInfo(const SourceString('?'), 0, UNKNOWN_TOKEN);
OLDNEW
« no previous file with comments | « dart/lib/compiler/implementation/scanner/string_scanner.dart ('k') | dart/lib/compiler/implementation/script.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698