OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 licenset hat can be found in the LICENSE file. | 3 // BSD-style licenset hat can be found in the LICENSE file. |
4 | 4 |
5 library fasta.scanner.recover; | 5 library fasta.scanner.recover; |
6 | 6 |
7 import '../../scanner/token.dart' show TokenType; | 7 import '../../scanner/token.dart' show TokenType; |
8 | 8 |
9 import '../fasta_codes.dart' | 9 import '../fasta_codes.dart' |
10 show | 10 show |
11 FastaCode, | 11 Code, |
12 codeAsciiControlCharacter, | 12 codeAsciiControlCharacter, |
13 codeEncoding, | 13 codeEncoding, |
14 codeExpectedHexDigit, | 14 codeExpectedHexDigit, |
15 codeMissingExponent, | 15 codeMissingExponent, |
16 codeNonAsciiIdentifier, | 16 codeNonAsciiIdentifier, |
17 codeNonAsciiWhitespace, | 17 codeNonAsciiWhitespace, |
18 codeUnexpectedDollarInString, | 18 codeUnexpectedDollarInString, |
19 codeUnmatchedToken, | 19 codeUnmatchedToken, |
20 codeUnterminatedComment, | 20 codeUnterminatedComment, |
21 codeUnterminatedString; | 21 codeUnterminatedString; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 if (errorTail == null) { | 165 if (errorTail == null) { |
166 error = next; | 166 error = next; |
167 } else { | 167 } else { |
168 errorTail.next = next; | 168 errorTail.next = next; |
169 next.previous = errorTail; | 169 next.previous = errorTail; |
170 } | 170 } |
171 errorTail = next; | 171 errorTail = next; |
172 next = next.next; | 172 next = next.next; |
173 } while (next is ErrorToken && first.errorCode == next.errorCode); | 173 } while (next is ErrorToken && first.errorCode == next.errorCode); |
174 | 174 |
175 FastaCode code = first.errorCode; | 175 Code code = first.errorCode; |
176 if (code == codeEncoding || | 176 if (code == codeEncoding || |
177 code == codeNonAsciiWhitespace || | 177 code == codeNonAsciiWhitespace || |
178 code == codeAsciiControlCharacter) { | 178 code == codeAsciiControlCharacter) { |
179 current = errorTail.next; | 179 current = errorTail.next; |
180 } else if (code == codeNonAsciiIdentifier) { | 180 } else if (code == codeNonAsciiIdentifier) { |
181 current = recoverIdentifier(first); | 181 current = recoverIdentifier(first); |
182 assert(current.next != null); | 182 assert(current.next != null); |
183 } else if (code == codeMissingExponent) { | 183 } else if (code == codeMissingExponent) { |
184 current = recoverExponent(); | 184 current = recoverExponent(); |
185 assert(current.next != null); | 185 assert(current.next != null); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 | 238 |
239 String closeBraceFor(String openBrace) { | 239 String closeBraceFor(String openBrace) { |
240 return const { | 240 return const { |
241 '(': ')', | 241 '(': ')', |
242 '[': ']', | 242 '[': ']', |
243 '{': '}', | 243 '{': '}', |
244 '<': '>', | 244 '<': '>', |
245 r'${': '}', | 245 r'${': '}', |
246 }[openBrace]; | 246 }[openBrace]; |
247 } | 247 } |
OLD | NEW |