package de.dhbw.compiler.xparser.test;

import static org.junit.Assert.assertEquals;

import java.io.StringReader;

import de.dhbw.compiler.xparser.ASTParser;
import de.dhbw.compiler.xparser.JFlexXScanner;
import de.dhbw.compiler.xparser.TokenReader;
import de.dhbw.compiler.xparser.Tree;

public abstract class ASTParseTreeTest extends ParseTreeTest {
    @Override
    protected void testParseTree(String in, String expected) throws Exception {
        JFlexXScanner scanner   = new JFlexXScanner(new StringReader(in));
        TokenReader reader	    = new TokenReader(scanner);
        ASTParser parser	    = new ASTParser(reader);

        Tree out = parser.parseProgram();

        if (out==null) {
            assertEquals(expected, out);
        } else {
            assertEquals(expected, out.toString());
        }
    }
}
