static ParseResult parse(String expression, NameValidator variableValidator) {
        ParseResult result = new ParseResult();
        try {
            Parser parser = new Parser(new Scanner("ignore", new StringReader(expression)));
            Java.Atom atom = parser.parseConditionalExpression();
            if (parser.peek().type == TokenType.END_OF_INPUT) {
                result.guessedVariables = new LinkedHashSet<>();
                result.operators = new LinkedHashSet<>();
                ValueExpressionVisitor visitor = new ValueExpressionVisitor(result, variableValidator);
                result.ok = atom.accept(visitor);
                result.invalidMessage = visitor.invalidMessage;
            }
        } catch (Exception ex) {
        }
        return result;
    }
@Test
    public void isValidAndSimpleCondition() {
        ParseResult result = parse("edge == edge", (arg) -> false);
        assertFalse(result.ok);

        result = parse("Math.sqrt(2)", (arg) -> false);
        assertTrue(result.ok, result.invalidMessage);
        assertTrue(result.guessedVariables.isEmpty());

        result = parse("Math.sqrt(my_speed)", (arg) -> arg.equals("my_speed"));
        assertTrue(result.ok, result.invalidMessage);
        assertEquals("[my_speed]", result.guessedVariables.toString());

        result = parse("edge.getDistance()", (arg) -> false);
        assertFalse(result.ok);

        result = parse("road_class == PRIMARY", (arg) -> false);
        assertFalse(result.ok);

        result = parse("toll == Toll.NO", (arg) -> false);
        assertFalse(result.ok);

        result = parse("priority * 2", (s) -> s.equals("priority"));
        assertTrue(result.ok, result.invalidMessage);
        assertEquals("[priority]", result.guessedVariables.toString());

        // LATER but requires accepting also EnumEncodedValue for value expression
        // result = parse("road_class.ordinal()*2", validVariable);
        // assertTrue(result.ok, result.invalidMessage);
        // assertTrue(parse("Math.sqrt(road_class.ordinal())", validVariable).ok);
    }