| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 library fasta.scanner.abstract_scanner; | 5 library fasta.scanner.abstract_scanner; |
| 6 | 6 |
| 7 import 'dart:collection' show ListMixin; | 7 import 'dart:collection' show ListMixin; |
| 8 | 8 |
| 9 import 'dart:typed_data' show Uint16List, Uint32List; | 9 import 'dart:typed_data' show Uint16List, Uint32List; |
| 10 | 10 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 | 153 |
| 154 /** | 154 /** |
| 155 * Appends a substring from the scan offset [:start:] to the current | 155 * Appends a substring from the scan offset [:start:] to the current |
| 156 * [:scanOffset:] plus the [:extraOffset:]. For example, if the current | 156 * [:scanOffset:] plus the [:extraOffset:]. For example, if the current |
| 157 * scanOffset is 10, then [:appendSubstringToken(5, -1):] will append the | 157 * scanOffset is 10, then [:appendSubstringToken(5, -1):] will append the |
| 158 * substring string [5,9). | 158 * substring string [5,9). |
| 159 * | 159 * |
| 160 * Note that [extraOffset] can only be used if the covered character(s) are | 160 * Note that [extraOffset] can only be used if the covered character(s) are |
| 161 * known to be ASCII. | 161 * known to be ASCII. |
| 162 */ | 162 */ |
| 163 void appendSubstringToken(TokenType info, int start, bool asciiOnly, | 163 void appendSubstringToken(TokenType type, int start, bool asciiOnly, |
| 164 [int extraOffset]); | 164 [int extraOffset]); |
| 165 | 165 |
| 166 /** Documentation in subclass [ArrayBasedScanner]. */ | 166 /** Documentation in subclass [ArrayBasedScanner]. */ |
| 167 void appendPrecedenceToken(TokenType info); | 167 void appendPrecedenceToken(TokenType type); |
| 168 | 168 |
| 169 /** Documentation in subclass [ArrayBasedScanner]. */ | 169 /** Documentation in subclass [ArrayBasedScanner]. */ |
| 170 int select(int choice, TokenType yes, TokenType no); | 170 int select(int choice, TokenType yes, TokenType no); |
| 171 | 171 |
| 172 /** Documentation in subclass [ArrayBasedScanner]. */ | 172 /** Documentation in subclass [ArrayBasedScanner]. */ |
| 173 void appendKeywordToken(Keyword keyword); | 173 void appendKeywordToken(Keyword keyword); |
| 174 | 174 |
| 175 /** Documentation in subclass [ArrayBasedScanner]. */ | 175 /** Documentation in subclass [ArrayBasedScanner]. */ |
| 176 void appendEofToken(); | 176 void appendEofToken(); |
| 177 | 177 |
| 178 /** Documentation in subclass [ArrayBasedScanner]. */ | 178 /** Documentation in subclass [ArrayBasedScanner]. */ |
| 179 void appendWhiteSpace(int next); | 179 void appendWhiteSpace(int next); |
| 180 | 180 |
| 181 /** Documentation in subclass [ArrayBasedScanner]. */ | 181 /** Documentation in subclass [ArrayBasedScanner]. */ |
| 182 void lineFeedInMultiline(); | 182 void lineFeedInMultiline(); |
| 183 | 183 |
| 184 /** Documentation in subclass [ArrayBasedScanner]. */ | 184 /** Documentation in subclass [ArrayBasedScanner]. */ |
| 185 void appendBeginGroup(TokenType info); | 185 void appendBeginGroup(TokenType type); |
| 186 | 186 |
| 187 /** Documentation in subclass [ArrayBasedScanner]. */ | 187 /** Documentation in subclass [ArrayBasedScanner]. */ |
| 188 int appendEndGroup(TokenType info, int openKind); | 188 int appendEndGroup(TokenType type, int openKind); |
| 189 | 189 |
| 190 /** Documentation in subclass [ArrayBasedScanner]. */ | 190 /** Documentation in subclass [ArrayBasedScanner]. */ |
| 191 void appendGt(TokenType info); | 191 void appendGt(TokenType type); |
| 192 | 192 |
| 193 /** Documentation in subclass [ArrayBasedScanner]. */ | 193 /** Documentation in subclass [ArrayBasedScanner]. */ |
| 194 void appendGtGt(TokenType info); | 194 void appendGtGt(TokenType type); |
| 195 | 195 |
| 196 /// Append [token] to the token stream. | 196 /// Append [token] to the token stream. |
| 197 void appendErrorToken(ErrorToken token); | 197 void appendErrorToken(ErrorToken token); |
| 198 | 198 |
| 199 /** | 199 /** |
| 200 * Returns a new comment from the scan offset [start] to the current | 200 * Returns a new comment from the scan offset [start] to the current |
| 201 * [scanOffset] plus the [extraOffset]. For example, if the current | 201 * [scanOffset] plus the [extraOffset]. For example, if the current |
| 202 * scanOffset is 10, then [appendSubstringToken(5, -1)] will append the | 202 * scanOffset is 10, then [appendSubstringToken(5, -1)] will append the |
| 203 * substring string [5,9). | 203 * substring string [5,9). |
| 204 * | 204 * |
| 205 * Note that [extraOffset] can only be used if the covered character(s) are | 205 * Note that [extraOffset] can only be used if the covered character(s) are |
| 206 * known to be ASCII. | 206 * known to be ASCII. |
| 207 */ | 207 */ |
| 208 CommentToken createCommentToken(TokenType info, int start, bool asciiOnly, | 208 CommentToken createCommentToken(TokenType type, int start, bool asciiOnly, |
| 209 [int extraOffset = 0]); | 209 [int extraOffset = 0]); |
| 210 | 210 |
| 211 /** | 211 /** |
| 212 * Returns a new dartdoc from the scan offset [start] to the current | 212 * Returns a new dartdoc from the scan offset [start] to the current |
| 213 * [scanOffset] plus the [extraOffset]. For example, if the current | 213 * [scanOffset] plus the [extraOffset]. For example, if the current |
| 214 * scanOffset is 10, then [appendSubstringToken(5, -1)] will append the | 214 * scanOffset is 10, then [appendSubstringToken(5, -1)] will append the |
| 215 * substring string [5,9). | 215 * substring string [5,9). |
| 216 * | 216 * |
| 217 * Note that [extraOffset] can only be used if the covered character(s) are | 217 * Note that [extraOffset] can only be used if the covered character(s) are |
| 218 * known to be ASCII. | 218 * known to be ASCII. |
| 219 */ | 219 */ |
| 220 DartDocToken createDartDocToken(TokenType info, int start, bool asciiOnly, | 220 DartDocToken createDartDocToken(TokenType type, int start, bool asciiOnly, |
| 221 [int extraOffset = 0]); | 221 [int extraOffset = 0]); |
| 222 | 222 |
| 223 /** Documentation in subclass [ArrayBasedScanner]. */ | 223 /** Documentation in subclass [ArrayBasedScanner]. */ |
| 224 void discardOpenLt(); | 224 void discardOpenLt(); |
| 225 | 225 |
| 226 /// Return true when at EOF. | 226 /// Return true when at EOF. |
| 227 bool atEndOfFile(); | 227 bool atEndOfFile(); |
| 228 | 228 |
| 229 Token tokenize() { | 229 Token tokenize() { |
| 230 while (!atEndOfFile()) { | 230 while (!atEndOfFile()) { |
| (...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 823 if (next > 127) { | 823 if (next > 127) { |
| 824 asciiOnlyLines = false; | 824 asciiOnlyLines = false; |
| 825 asciiOnlyComment = false; | 825 asciiOnlyComment = false; |
| 826 } | 826 } |
| 827 next = advance(); | 827 next = advance(); |
| 828 } | 828 } |
| 829 } | 829 } |
| 830 return next; | 830 return next; |
| 831 } | 831 } |
| 832 | 832 |
| 833 void appendComment(int start, TokenType info, bool asciiOnly) { | 833 void appendComment(int start, TokenType type, bool asciiOnly) { |
| 834 if (!includeComments) return; | 834 if (!includeComments) return; |
| 835 CommentToken newComment = createCommentToken(info, start, asciiOnly); | 835 CommentToken newComment = createCommentToken(type, start, asciiOnly); |
| 836 if (scanGenericMethodComments) { | 836 if (scanGenericMethodComments) { |
| 837 String value = newComment.lexeme; | 837 String value = newComment.lexeme; |
| 838 int length = value.length; | 838 int length = value.length; |
| 839 if (length > 5 && | 839 if (length > 5 && |
| 840 value.codeUnitAt(0) == $SLASH && | 840 value.codeUnitAt(0) == $SLASH && |
| 841 value.codeUnitAt(1) == $STAR && | 841 value.codeUnitAt(1) == $STAR && |
| 842 value.codeUnitAt(2) == $EQ) { | 842 value.codeUnitAt(2) == $EQ) { |
| 843 newComment = new CommentToken.fromString( | 843 newComment = new CommentToken.fromString( |
| 844 TokenType.GENERIC_METHOD_TYPE_ASSIGN, value, start); | 844 TokenType.GENERIC_METHOD_TYPE_ASSIGN, value, start); |
| 845 } else if (length > 6 && | 845 } else if (length > 6 && |
| 846 value.codeUnitAt(0) == $SLASH && | 846 value.codeUnitAt(0) == $SLASH && |
| 847 value.codeUnitAt(1) == $STAR && | 847 value.codeUnitAt(1) == $STAR && |
| 848 value.codeUnitAt(2) == $LT && | 848 value.codeUnitAt(2) == $LT && |
| 849 value.codeUnitAt(length - 1) == $SLASH && | 849 value.codeUnitAt(length - 1) == $SLASH && |
| 850 value.codeUnitAt(length - 2) == $STAR && | 850 value.codeUnitAt(length - 2) == $STAR && |
| 851 value.codeUnitAt(length - 3) == $GT) { | 851 value.codeUnitAt(length - 3) == $GT) { |
| 852 newComment = new CommentToken.fromString( | 852 newComment = new CommentToken.fromString( |
| 853 TokenType.GENERIC_METHOD_TYPE_LIST, value, start); | 853 TokenType.GENERIC_METHOD_TYPE_LIST, value, start); |
| 854 } | 854 } |
| 855 } | 855 } |
| 856 _appendToCommentStream(newComment); | 856 _appendToCommentStream(newComment); |
| 857 } | 857 } |
| 858 | 858 |
| 859 void appendDartDoc(int start, TokenType info, bool asciiOnly) { | 859 void appendDartDoc(int start, TokenType type, bool asciiOnly) { |
| 860 if (!includeComments) return; | 860 if (!includeComments) return; |
| 861 Token newComment = createDartDocToken(info, start, asciiOnly); | 861 Token newComment = createDartDocToken(type, start, asciiOnly); |
| 862 _appendToCommentStream(newComment); | 862 _appendToCommentStream(newComment); |
| 863 } | 863 } |
| 864 | 864 |
| 865 /** | 865 /** |
| 866 * Append the given token to the [tail] of the current stream of tokens. | 866 * Append the given token to the [tail] of the current stream of tokens. |
| 867 */ | 867 */ |
| 868 void appendToken(Token token) { | 868 void appendToken(Token token) { |
| 869 tail.next = token; | 869 tail.next = token; |
| 870 tail.next.previousToken = tail; | 870 tail.next.previousToken = tail; |
| 871 tail = tail.next; | 871 tail = tail.next; |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1289 switchToUint32(newLength); | 1289 switchToUint32(newLength); |
| 1290 } | 1290 } |
| 1291 } | 1291 } |
| 1292 | 1292 |
| 1293 void switchToUint32(int newLength) { | 1293 void switchToUint32(int newLength) { |
| 1294 final newArray = new Uint32List(newLength); | 1294 final newArray = new Uint32List(newLength); |
| 1295 newArray.setRange(0, arrayLength, array); | 1295 newArray.setRange(0, arrayLength, array); |
| 1296 array = newArray; | 1296 array = newArray; |
| 1297 } | 1297 } |
| 1298 } | 1298 } |
| OLD | NEW |