package javakurs.uebung11;

import java.util.ArrayList;
import java.util.List;

/**
 * {@link TopDownParserTest} is a test class for {@link TopDownParser}.
 *
 * @author Joerg Steffen, DFKI
 * @version $Id$
 */
public final class TopDownParserTest {

  /**
   * Would create a new instance of {@link TopDownParserTest}. Not to be used.
   */
  private TopDownParserTest() {

    // private constructor to enforce noninstantiability
  }


  /**
   * The main method; requires no arguments.
   *
   * @param args
   *          the arguments; not used here
   */
  public static void main(String[] args) {

    TopDownParser tdParser =
      new TopDownParser("data/uebung11/example.gram");

    // setup input
    String[][] testInputs = {
      { "john", "walks", "in", "the", "park" },
      { "john", "runs" , "in", "the", "park" }
    };

    for (int i = 0; i < testInputs.length; i++) {
      List<String> input = new ArrayList<String>();
      for (int j = 0; j < testInputs[i].length; j++) {
        System.out.print(testInputs[i][j] + " ");
        input.add(testInputs[i][j]);
      }
      System.out.println();
      // try to parse input
      System.out.println(tdParser.recognize(input));
    }
  }
}
