< prev index next >

src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Lexer.java

Print this page
rev 1391 : 8073613: Here documents: how to avoid string interpolation?

*** 1449,1461 **** skip(2); } else { skip(3); } ! // Scan identifier. final int identStart = position; final int identLength = scanIdentifier(); // Check for identifier. if (identLength == 0) { // Treat as shift. restoreState(saved); --- 1449,1474 ---- skip(2); } else { skip(3); } ! // Scan identifier. It might be quoted, indicating that no string editing should take place. ! final char quoteChar = ch0; ! final boolean noStringEditing = isStringDelimiter(quoteChar); ! if (noStringEditing) { ! skip(1); ! } final int identStart = position; final int identLength = scanIdentifier(); + if (noStringEditing) { + if (ch0 != quoteChar) { + error(Lexer.message("here.non.matching.delimiter"), last, position, position); + restoreState(saved); + return false; + } + skip(1); + } // Check for identifier. if (identLength == 0) { // Treat as shift. restoreState(saved);
*** 1521,1531 **** // Update end of string. stringState.setLimit(stringEnd); } // Edit string if appropriate. ! if (scripting && !stringState.isEmpty()) { editString(STRING, stringState); } else { // Add here string. add(STRING, stringState.position, stringState.limit); } --- 1534,1544 ---- // Update end of string. stringState.setLimit(stringEnd); } // Edit string if appropriate. ! if (!noStringEditing && !stringState.isEmpty()) { editString(STRING, stringState); } else { // Add here string. add(STRING, stringState.position, stringState.limit); }
< prev index next >