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

Side by Side Diff: pkg/front_end/lib/src/fasta/parser/parser.dart

Issue 2794833003: Use SubStringScanner to scan generic comments. (Closed)
Patch Set: Revert formatting changes. Created 3 years, 8 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
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/scanner/string_scanner.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.parser.parser; 5 library fasta.parser.parser;
6 6
7 import '../fasta_codes.dart' 7 import '../fasta_codes.dart'
8 show 8 show
9 FastaCode, 9 FastaCode,
10 FastaMessage, 10 FastaMessage,
(...skipping 3816 matching lines...) Expand 10 before | Expand all | Expand 10 after
3827 return tokens; 3827 return tokens;
3828 } 3828 }
3829 } 3829 }
3830 } 3830 }
3831 } 3831 }
3832 return token; 3832 return token;
3833 } 3833 }
3834 3834
3835 /// Scans the given [code], and returns the tokens, otherwise returns `null`. 3835 /// Scans the given [code], and returns the tokens, otherwise returns `null`.
3836 Token _scanGenericMethodComment(String code, int offset) { 3836 Token _scanGenericMethodComment(String code, int offset) {
3837 // TODO(scheglov) Let StringScanner to specify the string offset. 3837 var scanner = new SubStringScanner(offset, code);
3838 var scanner = new StringScanner(' ' * offset + code);
3839 Token firstToken = scanner.tokenize(); 3838 Token firstToken = scanner.tokenize();
3840 if (scanner.hasErrors) { 3839 if (scanner.hasErrors) {
3841 return null; 3840 return null;
3842 } 3841 }
3843 return firstToken; 3842 return firstToken;
3844 } 3843 }
3845 3844
3846 void _injectTokenList(Token beforeToken, Token firstToken) { 3845 void _injectTokenList(Token beforeToken, Token firstToken) {
3847 // Scanner creates a cyclic EOF token. 3846 // Scanner creates a cyclic EOF token.
3848 Token lastToken = firstToken; 3847 Token lastToken = firstToken;
3849 while (lastToken.next.info != EOF_INFO) { 3848 while (lastToken.next.info != EOF_INFO) {
3850 lastToken = lastToken.next; 3849 lastToken = lastToken.next;
3851 } 3850 }
3852 // Inject these new tokens into the stream. 3851 // Inject these new tokens into the stream.
3853 Token previous = beforeToken.previous; 3852 Token previous = beforeToken.previous;
3854 lastToken.setNext(beforeToken); 3853 lastToken.setNext(beforeToken);
3855 previous.setNext(firstToken); 3854 previous.setNext(firstToken);
3856 beforeToken = firstToken; 3855 beforeToken = firstToken;
3857 } 3856 }
3858 } 3857 }
3859 3858
3860 typedef FastaMessage NoArgument(Uri uri, int charOffset); 3859 typedef FastaMessage NoArgument(Uri uri, int charOffset);
3861 3860
3862 typedef FastaMessage TokenArgument(Uri uri, int charOffset, Token token); 3861 typedef FastaMessage TokenArgument(Uri uri, int charOffset, Token token);
3863 3862
3864 typedef FastaMessage StringArgument(Uri uri, int charOffset, String string); 3863 typedef FastaMessage StringArgument(Uri uri, int charOffset, String string);
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/scanner/string_scanner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698