* 字符串边界符
* @return 字符串的结束位置
*/
private static int findString(String line, int start, int end,
Object[] words, int wordSize, char c) {
MixedStringExpression exp = null;
StringBuilder s = new StringBuilder();
quotation: while (start < end) {
char d = line.charAt(start);
switch (d) {
case '$':
if (!Character.isJavaIdentifierStart(line.charAt(start + 1))) {
break;
}
case '`':
if (exp == null) {
exp = new MixedStringExpression();
}
exp.add(s.toString());
s.setLength(0);
if (d == '$') {
start = findVariable(line, start + 1, end, words, wordSize, STRING);
} else {
start = findExpression(line, start + 1, end, words, wordSize, '`');
}
exp.add((IExpression) words[wordSize]);
continue;
case '\\': {
// 启用字符转义, 转义回车,换行制表符以及转义字符
start++;
d = line.charAt(start);
switch (d) {
case 'n':
d = '\n';
break;
case 'r':
d = '\r';
break;
case 't':
d = '\t';
break;
case '`':
case '$':
case '"':
case '\'':
case '\\':
case '.':
case '[':
case ']':
break;
default:
s.append('\\');
}
break;
}
default:
// 寻找成对的字符串标识符
if (d == c) {
if (exp == null) {
words[wordSize] = new StringExpression(s.toString());
} else {
exp.add(s.toString());
words[wordSize] = exp;
}
break quotation;
}
}