// Path: src/main/java/org/dice/parsing/ast/Expression.java
// public interface Expression {
// 	public String evaluate();
// }


import org.dice.parsing.ast.Expression;
import org.junit.Test;
import static junit.framework.TestCase.assertFalse;
import static junit.framework.TestCase.assertTrue;
import static junit.framework.TestCase.assertEquals;

    @Test
    // Note that solr always parses NOT correctly as it's a unary operator (and the reasons for the
    // issues with boolean operator precedence resolve around converting boolean to unary operators
    public void parsesNotOperator(){
        // Note - see comments above
        assertEquals("NOT java", parseWithoutErrors("not java"));
        assertEquals("(NOT java AND sql)", parseWithoutErrors("not java and sql"));
        assertEquals("((NOT java AND sql) OR ruby)", parseWithoutErrors("not java and sql or ruby"));
        assertEquals("(NOT (java AND sql) OR ruby)", parseWithoutErrors("not (java and sql) or ruby"));

    }

    private String parseWithoutErrors(String input){
        RecursiveDescentParser parser = new RecursiveDescentParser(new Lexer(input), WILDCARD_TOKEN);
        final Expression ast = parser.parse();
        assertFalse(parser.hasErrors());
        return ast.evaluate();
    }

    private String parseWithErrors(String input){

        RecursiveDescentParser parser = new RecursiveDescentParser(new Lexer(input), WILDCARD_TOKEN);
        final Expression ast = parser.parse();
        assertTrue(parser.hasErrors());
        return ast.evaluate();
    }

    private int getParserError(String input){
        RecursiveDescentParser parser = new RecursiveDescentParser(new Lexer(input),  WILDCARD_TOKEN);
// Path: src/main/java/org/dice/parsing/ast/Expression.java
// public interface Expression {
// 	public String evaluate();
// }


// Path: src/test/java/org/dice/parsing/TestRecursiveDescentParser.java
import org.dice.parsing.ast.Expression;
import org.junit.Test;
import static junit.framework.TestCase.assertFalse;
import static junit.framework.TestCase.assertTrue;
import static junit.framework.TestCase.assertEquals;


    @Test
    // Note that solr always parses NOT correctly as it's a unary operator (and the reasons for the
    // issues with boolean operator precedence resolve around converting boolean to unary operators
    public void parsesNotOperator(){
        // Note - see comments above
        assertEquals("NOT java", parseWithoutErrors("not java"));
        assertEquals("(NOT java AND sql)", parseWithoutErrors("not java and sql"));
        assertEquals("((NOT java AND sql) OR ruby)", parseWithoutErrors("not java and sql or ruby"));
        assertEquals("(NOT (java AND sql) OR ruby)", parseWithoutErrors("not (java and sql) or ruby"));

    }

    private String parseWithoutErrors(String input){
        RecursiveDescentParser parser = new RecursiveDescentParser(new Lexer(input), WILDCARD_TOKEN);
        final Expression ast = parser.parse();
        assertFalse(parser.hasErrors());
        return ast.evaluate();
    }

    private String parseWithErrors(String input){

        RecursiveDescentParser parser = new RecursiveDescentParser(new Lexer(input), WILDCARD_TOKEN);
        final Expression ast = parser.parse();
        assertTrue(parser.hasErrors());
        return ast.evaluate();
    }

    private int getParserError(String input){
        RecursiveDescentParser parser = new RecursiveDescentParser(new Lexer(input),  WILDCARD_TOKEN);
        final Expression ast = parser.parse();