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

Unified Diff: pkg/analyzer/lib/src/generated/parser.dart

Issue 2304923002: Allow surrogates in string literals. (Closed)
Patch Set: Fixed another test Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/lib/src/generated/parser.dart
diff --git a/pkg/analyzer/lib/src/generated/parser.dart b/pkg/analyzer/lib/src/generated/parser.dart
index cb2a41218b94e69df3cb937443cced98691977ad..24f8a2cd6f5bd0a68b73a01eac6ce4f2f4d61081 100644
--- a/pkg/analyzer/lib/src/generated/parser.dart
+++ b/pkg/analyzer/lib/src/generated/parser.dart
@@ -98,10 +98,10 @@ Map<String, MethodTrampoline> methodTable_Parser = <String, MethodTrampoline>{
'parseWithClause_0':
new MethodTrampoline(0, (Parser target) => target.parseWithClause()),
'advance_0': new MethodTrampoline(0, (Parser target) => target._advance()),
- 'appendScalarValue_5': new MethodTrampoline(
+ 'appendCodePoint_5': new MethodTrampoline(
5,
(Parser target, arg0, arg1, arg2, arg3, arg4) =>
- target._appendScalarValue(arg0, arg1, arg2, arg3, arg4)),
+ target._appendCodePoint(arg0, arg1, arg2, arg3, arg4)),
'computeStringValue_3': new MethodTrampoline(
3,
(Parser target, arg0, arg1, arg2) =>
@@ -2078,25 +2078,24 @@ class Parser {
}
/**
- * Append the character equivalent of the given [scalarValue] to the given
+ * Append the character equivalent of the given [codePoint] to the given
* [builder]. Use the [startIndex] and [endIndex] to report an error, and
- * don't append anything to the builder, if the scalar value is invalid. The
+ * don't append anything to the builder, if the code point is invalid. The
* [escapeSequence] is the escape sequence that was parsed to produce the
- * scalar value (used for error reporting).
+ * code point (used for error reporting).
*/
- void _appendScalarValue(StringBuffer buffer, String escapeSequence,
- int scalarValue, int startIndex, int endIndex) {
- if (scalarValue < 0 ||
- scalarValue > Character.MAX_CODE_POINT ||
- (scalarValue >= 0xD800 && scalarValue <= 0xDFFF)) {
+ void _appendCodePoint(StringBuffer buffer, String source,
+ int codePoint, int startIndex, int endIndex) {
+ if (codePoint < 0 || codePoint > Character.MAX_CODE_POINT) {
+ String escapeSequence = source.substring(startIndex, endIndex + 1);
_reportErrorForCurrentToken(
ParserErrorCode.INVALID_CODE_POINT, [escapeSequence]);
return;
}
- if (scalarValue < Character.MAX_VALUE) {
- buffer.writeCharCode(scalarValue);
+ if (codePoint < Character.MAX_VALUE) {
+ buffer.writeCharCode(codePoint);
} else {
- buffer.write(Character.toChars(scalarValue));
+ buffer.write(Character.toChars(codePoint));
}
}
@@ -8095,8 +8094,7 @@ class Parser {
// Illegal escape sequence: not enough or too many hex digits
_reportErrorForCurrentToken(ParserErrorCode.INVALID_UNICODE_ESCAPE);
}
- _appendScalarValue(buffer, lexeme.substring(index, currentIndex + 1),
- value, index, currentIndex);
+ _appendCodePoint(buffer, lexeme, value, index, currentIndex);
return currentIndex + 1;
} else {
if (currentIndex + 3 >= length) {
@@ -8115,9 +8113,9 @@ class Parser {
// Illegal escape sequence: invalid hex digits
_reportErrorForCurrentToken(ParserErrorCode.INVALID_UNICODE_ESCAPE);
} else {
- _appendScalarValue(
+ _appendCodePoint(
buffer,
- lexeme.substring(index, currentIndex + 1),
+ lexeme,
(((((Character.digit(firstDigit, 16) << 4) +
Character.digit(secondDigit, 16)) <<
4) +

Powered by Google App Engine
This is Rietveld 408576698