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.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 Loading... |
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); |
OLD | NEW |