package net.woodyfolsom.msproj.sgf;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

import org.antlr.runtime.ANTLRInputStream;
import org.antlr.runtime.ANTLRStringStream;
import org.antlr.runtime.CommonTokenStream;
import org.antlr.runtime.RecognitionException;
import org.junit.Test;

public class SGFParserTest {

	@Test
	public void testParse() throws RecognitionException, IOException {
		FileInputStream fis = new FileInputStream(new File(
				"data/games/1334-gokifu-20120916-Gu_Li-Lee_Sedol.sgf"));
		ANTLRStringStream in = new ANTLRInputStream(fis);
		SGFLexer lexer = new SGFLexer(in);
		CommonTokenStream tokens = new CommonTokenStream(lexer);
		SGFParser parser = new SGFParser(tokens);
		SGFNodeCollection nodeCollection = parser.collection();

		System.out.println("To SGF:");
		System.out.println(nodeCollection.toSGF());
		System.out.println("");
	}
	
	@Test
	public void testParse9x9() throws RecognitionException, IOException {
		FileInputStream fis = new FileInputStream(new File(
				"data/games/pro9x9/game001.sgf"));
		ANTLRStringStream in = new ANTLRInputStream(fis);
		SGFLexer lexer = new SGFLexer(in);
		CommonTokenStream tokens = new CommonTokenStream(lexer);
		SGFParser parser = new SGFParser(tokens);
		SGFNodeCollection nodeCollection = parser.collection();

		System.out.println("To SGF:");
		System.out.println(nodeCollection.toSGF());
		System.out.println("");
	}
}
