| 1798 | } |
| 1799 | |
| 1800 | protected final void scanString2() { |
| 1801 | { |
| 1802 | boolean hasSpecial = false; |
| 1803 | int startIndex = pos + 1; |
| 1804 | int endIndex = -1; // text.indexOf('\'', startIndex); |
| 1805 | for (int i = startIndex; i < text.length(); ++i) { |
| 1806 | final char ch = text.charAt(i); |
| 1807 | if (ch == '\\') { |
| 1808 | hasSpecial = true; |
| 1809 | continue; |
| 1810 | } |
| 1811 | if (ch == '\'') { |
| 1812 | endIndex = i; |
| 1813 | break; |
| 1814 | } |
| 1815 | } |
| 1816 | |
| 1817 | if (endIndex == -1) { |
| 1818 | throw new ParserException("unclosed str. " + info()); |
| 1819 | } |
| 1820 | |
| 1821 | String stringVal; |
| 1822 | if (token == Token.AS) { |
| 1823 | stringVal = text.substring(pos, endIndex + 1); |
| 1824 | } else { |
| 1825 | if (startIndex == endIndex) { |
| 1826 | stringVal = ""; |
| 1827 | } else { |
| 1828 | stringVal = text.substring(startIndex, endIndex); |
| 1829 | } |
| 1830 | } |
| 1831 | // hasSpecial = stringVal.indexOf('\\') != -1; |
| 1832 | |
| 1833 | if (!hasSpecial) { |
| 1834 | this.stringVal = stringVal; |
| 1835 | int pos = endIndex + 1; |
| 1836 | char ch = charAt(pos); |
| 1837 | if (ch != '\'') { |
| 1838 | this.pos = pos; |
| 1839 | this.ch = ch; |
| 1840 | token = LITERAL_CHARS; |
| 1841 | return; |
| 1842 | } |
| 1843 | } |
| 1844 | } |
| 1845 | |
| 1846 | mark = pos; |
| 1847 | boolean hasSpecial = false; |
| 1848 | for (; ; ) { |
| 1849 | if (isEOF()) { |
| 1850 | lexError("unclosed.str.lit"); |
| 1851 | return; |
| 1852 | } |
| 1853 | |
| 1854 | ch = charAt(++pos); |
| 1855 | |
| 1856 | if (ch == '\\') { |
| 1857 | scanChar(); |