allowed newlines in strings and error other special chars not handled by mc itself.

This commit is contained in:
gnembon committed 2020-01-06 23:49:01 -04:00
1 parent 6ac249968a
commit f76afb5b2c
1 file changed
+34 -5
+34 -5
View File
@@ -166,15 +166,44 @@ public class Tokenizer implements Iterator<Tokenizer.Token>
{
if (ch == '\\')
{
pos++;
char nextChar = peekNextChar();
if (nextChar == 'n')
{
token.append('\n');
}
else if (nextChar == 't')
{
throw new ExpressionException(context, this.expression, token,
"Tab character is not supported");
//token.append('\t');
}
else if (nextChar == 'r')
{
throw new ExpressionException(context, this.expression, token,
"Carriage return character is not supported");
//token.append('\r');
}
else if (nextChar == '\\' || nextChar == '\'')
{
token.append(nextChar);
}
else
{
pos--;
linepos--;
}
pos+=2;
linepos+=2;
if (pos == input.length() && expression != null && context != null)
throw new ExpressionException(context, this.expression, token, "Program truncated");
}
else
{
token.append(input.charAt(pos++));
linepos++;
if (pos == input.length() && expression != null && context != null)
throw new ExpressionException(context, this.expression, token, "Program truncated");
}
token.append(input.charAt(pos++));
linepos++;
if (pos == input.length() && expression != null && context != null)
throw new ExpressionException(context, this.expression, token, "Program truncated");
ch = input.charAt(pos);
}
pos++;