equal
deleted
inserted
replaced
97 |
97 |
98 /** Should the string's escapes be translated? |
98 /** Should the string's escapes be translated? |
99 */ |
99 */ |
100 protected boolean shouldTranslateEscapes; |
100 protected boolean shouldTranslateEscapes; |
101 |
101 |
|
102 /** Has the string broken escapes? |
|
103 */ |
|
104 protected boolean hasBrokenEscapes; |
|
105 |
102 protected ScannerFactory fac; |
106 protected ScannerFactory fac; |
103 |
107 |
104 // The set of lint options currently in effect. It is initialized |
108 // The set of lint options currently in effect. It is initialized |
105 // from the context, and then is set/reset as needed by Attr as it |
109 // from the context, and then is set/reset as needed by Attr as it |
106 // visits all the various parts of the trees during attribution. |
110 // visits all the various parts of the trees during attribution. |
259 case '\'': |
263 case '\'': |
260 case '\"': |
264 case '\"': |
261 case '\\': |
265 case '\\': |
262 reader.putChar(true); break; |
266 reader.putChar(true); break; |
263 default: |
267 default: |
|
268 hasBrokenEscapes = true; |
264 lexError(reader.bp, Errors.IllegalEscChar); |
269 lexError(reader.bp, Errors.IllegalEscChar); |
265 } |
270 } |
266 } |
271 } |
267 } else if (reader.bp != reader.buflen) { |
272 } else if (reader.bp != reader.buflen) { |
268 reader.putChar(true); |
273 reader.putChar(true); |
424 */ |
429 */ |
425 private void scanString(int pos) { |
430 private void scanString(int pos) { |
426 // Clear flags. |
431 // Clear flags. |
427 shouldStripIndent = false; |
432 shouldStripIndent = false; |
428 shouldTranslateEscapes = false; |
433 shouldTranslateEscapes = false; |
|
434 hasBrokenEscapes = false; |
429 // Check if text block string methods are present. |
435 // Check if text block string methods are present. |
430 boolean hasTextBlockSupport = TextBlockSupport.hasSupport(); |
436 boolean hasTextBlockSupport = TextBlockSupport.hasSupport(); |
431 // Track the end of first line for error recovery. |
437 // Track the end of first line for error recovery. |
432 int firstEOLN = -1; |
438 int firstEOLN = -1; |
433 // Attempt to scan for up to 3 double quotes. |
439 // Attempt to scan for up to 3 double quotes. |
1036 } |
1042 } |
1037 // Remove incidental indentation. |
1043 // Remove incidental indentation. |
1038 string = TextBlockSupport.stripIndent(string); |
1044 string = TextBlockSupport.stripIndent(string); |
1039 } |
1045 } |
1040 // Translate escape sequences if present. |
1046 // Translate escape sequences if present. |
1041 if (shouldTranslateEscapes) { |
1047 if (shouldTranslateEscapes && !hasBrokenEscapes) { |
1042 string = TextBlockSupport.translateEscapes(string); |
1048 string = TextBlockSupport.translateEscapes(string); |
1043 } |
1049 } |
1044 // Build string token. |
1050 // Build string token. |
1045 return new StringToken(tk, pos, endPos, string, comments); |
1051 return new StringToken(tk, pos, endPos, string, comments); |
1046 } |
1052 } |