Index: pkg/front_end/lib/src/scanner/errors.dart |
diff --git a/pkg/front_end/lib/src/scanner/errors.dart b/pkg/front_end/lib/src/scanner/errors.dart |
index ca2a20972639926508bfc0aea952ad0044896006..93b7fb0d26f87e3896c2763cf5b583906d9a231a 100644 |
--- a/pkg/front_end/lib/src/scanner/errors.dart |
+++ b/pkg/front_end/lib/src/scanner/errors.dart |
@@ -5,13 +5,20 @@ |
import 'package:front_end/src/base/errors.dart'; |
import 'package:front_end/src/fasta/fasta_codes.dart'; |
import 'package:front_end/src/fasta/scanner/error_token.dart'; |
-import 'package:front_end/src/scanner/token.dart' show Token; |
+import 'package:front_end/src/scanner/token.dart' show Token, TokenType; |
import 'package:front_end/src/fasta/scanner/token_constants.dart'; |
/** |
* The error codes used for errors detected by the scanner. |
*/ |
class ScannerErrorCode extends ErrorCode { |
+ /** |
+ * Parameters: |
+ * 0: the token that was expected but not found |
+ */ |
+ static const ScannerErrorCode EXPECTED_TOKEN = |
+ const ScannerErrorCode('EXPECTED_TOKEN', "Expected to find '{0}'."); |
+ |
/** |
* Parameters: |
* 0: the illegal character |
@@ -25,6 +32,9 @@ class ScannerErrorCode extends ErrorCode { |
static const ScannerErrorCode MISSING_HEX_DIGIT = const ScannerErrorCode( |
'MISSING_HEX_DIGIT', "Hexidecimal digit expected."); |
+ static const ScannerErrorCode MISSING_IDENTIFIER = |
+ const ScannerErrorCode('MISSING_IDENTIFIER', "Expected an identifier."); |
+ |
static const ScannerErrorCode MISSING_QUOTE = |
const ScannerErrorCode('MISSING_QUOTE', "Expected quote (' or \")."); |
@@ -119,9 +129,20 @@ void translateErrorToken(ErrorToken token, ReportError reportError) { |
return _makeError(ScannerErrorCode.ILLEGAL_CHARACTER, [token.character]); |
default: |
- if (errorCode == codeUnmatchedToken || |
- errorCode == codeUnexpectedDollarInString) { |
- return null; |
+ if (errorCode == codeUnmatchedToken) { |
+ TokenType type = token.begin?.type; |
+ if (type == TokenType.OPEN_CURLY_BRACKET || |
+ type == TokenType.STRING_INTERPOLATION_EXPRESSION) { |
+ return _makeError(ScannerErrorCode.EXPECTED_TOKEN, ['}']); |
+ } |
+ if (type == TokenType.OPEN_SQUARE_BRACKET) { |
+ return _makeError(ScannerErrorCode.EXPECTED_TOKEN, [']']); |
+ } |
+ if (type == TokenType.OPEN_PAREN) { |
+ return _makeError(ScannerErrorCode.EXPECTED_TOKEN, [')']); |
+ } |
+ } else if (errorCode == codeUnexpectedDollarInString) { |
+ return _makeError(ScannerErrorCode.MISSING_IDENTIFIER, null); |
} |
throw new UnimplementedError('$errorCode'); |
} |