expression parser supports a backslash in a variables name; see #581

This commit is contained in:
hneemann 2020-12-20 19:10:37 +01:00
parent d03cc1c492
commit dbce369808
2 changed files with 3 additions and 2 deletions

View File

@ -17,9 +17,9 @@ public class Tokenizer {
enum Token {UNKNOWN, IDENT, AND, OR, NOT, XOR, OPEN, CLOSE, ONE, ZERO, EOF, COMMA, EQUAL, NOTEQUAL, POSTNOT}
private final Reader in;
private final StringBuilder builder;
private Token token;
private boolean isToken;
private StringBuilder builder;
private boolean isUnreadChar = false;
private int unreadChar;
@ -174,7 +174,7 @@ public class Tokenizer {
private boolean isIdentChar(int c) {
return (c >= 'a' && c <= 'z')
|| (c >= 'A' && c <= 'Z')
|| (c == '_');
|| (c == '_') || (c == '\\');
}
private boolean isNumberChar(int c) {

View File

@ -27,6 +27,7 @@ public class ParserTest extends TestCase {
public void testIdent() throws Exception {
assertEquals(new Variable("C"), createSingle("C"));
assertEquals(new Variable("A_1"), createSingle("A_1"));
assertEquals(new Variable("A\\_1"), createSingle("A\\_1"));
}
public void testConst() throws Exception {