Package hampi.grammars

Examples of hampi.grammars.Grammar


    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "expr", 150, false);
    assertNotNull(boundedRegexp);
  }

  public void test6() throws Exception{
    Grammar g = new Parser(GrammarTests.DIR + "test_arithm.txt").parse();
    GrammarStringBounder gsb = new GrammarStringBounder();
    int bound = 40;
    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "S", bound, false);
    assertNotNull(boundedRegexp);
  }
View Full Code Here


    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "S", bound, false);
    assertNotNull(boundedRegexp);
  }

  public void testSmallSQL() throws Exception{
    Grammar g = new Parser(GrammarTests.DIR + "small_sql.txt").parse();
    GrammarStringBounder gsb = new GrammarStringBounder();
    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "Select", 20, true);
    assertNotNull(boundedRegexp);
  }
View Full Code Here

    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "Select", 20, true);
    assertNotNull(boundedRegexp);
  }

  public void testEcmascript() throws Exception{
    Grammar g = new Parser(GrammarTests.DIR + "ecmascript.txt").parse();
    GrammarStringBounder gsb = new GrammarStringBounder();
    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "FunctionDeclaration", 27, true);
    assertNotNull(boundedRegexp);
  }
View Full Code Here

    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "FunctionDeclaration", 27, true);
    assertNotNull(boundedRegexp);
  }

  public void testTinySQL() throws Exception{
    Grammar g = new Parser(GrammarTests.DIR + "tiny_SQL.txt").parse();
    GrammarStringBounder gsb = new GrammarStringBounder();
    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "SelectStmt", 26, false);
    //"SELECT" is one terminal and 6 characters
    assertNotNull(boundedRegexp);
    //    System.out.println(boundedRegexp);
View Full Code Here

    }
  }

  //stack overflow because of production T = T;
  public void testUselessProductionCycle1() throws Exception{
    Grammar g = new Parser(GrammarTests.DIR + "testUselessProductionCycle1.txt").parse();
    GrammarStringBounder gsb = new GrammarStringBounder();
    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "S", 1, false);
    assertNotNull(boundedRegexp);
  }
View Full Code Here

    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "S", 1, false);
    assertNotNull(boundedRegexp);
  }

  public void testUselessProductionCycle2() throws Exception{
    Grammar g = new Parser(GrammarTests.DIR + "testUselessProductionCycle2.txt").parse();
    GrammarStringBounder gsb = new GrammarStringBounder();
    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "S", 3, false);
    assertNotNull(boundedRegexp);
  }
View Full Code Here

public class GrammarTests extends TestCase{

  public static final String DIR = "tests/resources/";

  public void testCopy1() throws Exception{
    Grammar g = new Parser(DIR + "test_cyk1.txt").parse();
    Grammar g1 = g.makeCopy();
    assertEquals(g.toString(), g1.toString());
    assertEquals(g, g1);
    assertTrue(g != g1);
  }
View Full Code Here

    assertEquals(g, g1);
    assertTrue(g != g1);
  }

  public void testCopy2() throws Exception{
    Grammar g = new Parser(DIR + "ecmascript.txt").parse();
    Grammar g1 = g.makeCopy();
    assertEquals(g.toString(), g1.toString());
    assertEquals(g, g1);
    assertTrue(g != g1);
  }
View Full Code Here

  public void testNonCNF17() throws Exception{
    checkNonCNF("expr.txt", "expr");
  }

  public void testNonCNF18() throws Exception{
    Grammar g = new Parser(DIR + "test_cnf1.txt").parse();
    assertTrue(!g.isCNF());

    List<Grammar> steps = new ArrayList<Grammar>();
    Grammar gCNF = new CNFConverter().convertToCNF(g, "S", steps);

    System.out.println("orig :\n" + g);
    System.out.println("step0:\n" + steps.get(0));
    System.out.println("step1:\n" + steps.get(1));
    compareIgnoreNewlines(steps.get(1).toString(), DIR + "test_cnf1_step1_expected.txt");

    System.out.println("step2:\n" + steps.get(2));
    compareIgnoreNewlines(steps.get(2).toString(), DIR + "test_cnf1_step2_expected.txt");

    System.out.println("step3:\n" + steps.get(3));
    compareIgnoreNewlines(steps.get(3).toString(), DIR + "test_cnf1_step3_expected.txt");

    System.out.println("step4:\n" + steps.get(4));
    compareIgnoreNewlines(steps.get(4).toString(), DIR + "test_cnf1_step4_expected.txt");

    System.out.println("step5:\n" + gCNF);

    assertEquals(5, steps.size());
    compareIgnoreNewlines(gCNF.toString(), DIR + "test_cnf1_expected.txt");

    assertTrue("Not in CNF\n" + gCNF.toString(), gCNF.isCNF());

  }
View Full Code Here

    assertTrue("Not in CNF\n" + gCNF.toString(), gCNF.isCNF());

  }

  public void testNonCNF19() throws Exception{
    Grammar gCNF = checkNonCNF("test_cyk_ecmascript1.txt", "FunctionDeclaration");
    System.out.println(gCNF);
  }
View Full Code Here

TOP

Related Classes of hampi.grammars.Grammar

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.