Package hampi.grammars

Examples of hampi.grammars.Grammar


    Grammar gCNF = checkNonCNF("test_cyk_ecmascript1.txt", "FunctionDeclaration");
    System.out.println(gCNF);
  }

  public void testReplace1() throws Exception{
    Grammar g = new Parser(DIR + "test_replace1.txt").parse();
    GrammarElementReplacer ger = new GrammarElementReplacer(g.getNonterminal("X"), g.getNonterminal("S"));
    g.accept(ger);
    compareIgnoreNewlines(g.toString(), DIR + "test_replace1_expected.txt");
  }
View Full Code Here


    compareIgnoreNewlines(g.toString(), DIR + "test_replace1_expected.txt");
  }

  //----------------------------------------------------------------------
  private Grammar checkNonCNF(String string, String start) throws IOException{
    Grammar g = new Parser(DIR + string).parse();
    assertTrue(!g.isCNF());

    Grammar gCNF = new CNFConverter().convertToCNF(g, start);
    assertTrue("not in CNF:\n" + gCNF, gCNF.isCNF());
    return gCNF;
  }
View Full Code Here

    assertTrue("not in CNF:\n" + gCNF, gCNF.isCNF());
    return gCNF;
  }

  private void checkCNF(String string, String start) throws IOException{
    Grammar g = new Parser(DIR + string).parse();
    assertTrue(g.isCNF());

    Grammar gCNF = new CNFConverter().convertToCNF(g, start);
    assertEquals(g, gCNF);
    assertTrue(gCNF.isCNF());
  }
View Full Code Here

      assertTrue(sol.isValidFor(c));
    }
  }

  public void testGrammarBound1() throws Exception{
    Grammar g = new Parser(GrammarTests.DIR + "test_generate_parent.txt").parse();
    GrammarStringBounder gsb = new GrammarStringBounder();
    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "expr", 16, false);

    Hampi h = new Hampi();
    h.setSolver(stp());
View Full Code Here

    assertTrue(solve.isValidFor(c));
    System.out.println(solve);
  }

  public void testGrammarBound2() throws Exception{
    Grammar g = new Parser(GrammarTests.DIR + "test_arithm.txt").parse();
    GrammarStringBounder gsb = new GrammarStringBounder();
    int bound = 24;
    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "S", bound, false);
    Set<Character> alpha = boundedRegexp.getUsedCharacters();
    Hampi h = new Hampi();
View Full Code Here

    System.out.println(solve);

  }

  public void testGrammarBound3() throws Exception{
    Grammar g = new Parser(GrammarTests.DIR + "test_arithm.txt").parse();
    GrammarStringBounder gsb = new GrammarStringBounder();
    int bound = 11;
    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "S", bound, false);
    Set<Character> alpha = boundedRegexp.getUsedCharacters();
    Hampi h = new Hampi();
View Full Code Here

    assertTrue(solve.isValidFor(c));
    System.out.println(solve);
  }

  public void testGrammarBound4() throws Exception{
    Grammar g = new Parser(GrammarTests.DIR + "test_arithm.txt").parse();
    GrammarStringBounder gsb = new GrammarStringBounder();
    int bound = 9;
    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "S", bound, false);
    Set<Character> alpha = boundedRegexp.getUsedCharacters();
    Hampi h = new Hampi();
View Full Code Here

    }
    return result;
  }

  public void testGrammarBound5() throws Exception{
    Grammar g = new Parser(GrammarTests.DIR + "tiny_SQL.txt").parse();
    GrammarStringBounder gsb = new GrammarStringBounder();
    int bound = 21;
    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "UpdateStmt", bound, false);
    Set<Character> alpha = boundedRegexp.getUsedCharacters();
    Hampi h = new Hampi();
View Full Code Here

    assertTrue(solve.isSatisfiable());
    System.out.println(solve);
  }

  public void testGrammarBound6() throws Exception{
    Grammar g = new Parser(GrammarTests.DIR + "tiny_SQL.txt").parse();
    GrammarStringBounder gsb = new GrammarStringBounder();
    int bound = 21;
    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "UpdateStmt", bound, false);
    Set<Character> alpha = boundedRegexp.getUsedCharacters();
    Hampi h = new Hampi();
View Full Code Here

    assertTrue(solve.isSatisfiable());
    System.out.println(solve);
  }

  public void testGrammarBound7_comment() throws Exception{
    Grammar g = new Parser(GrammarTests.DIR + "tiny_SQL.txt").parse();
    GrammarStringBounder gsb = new GrammarStringBounder();
    int bound = 20;
    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "S", bound, false);
    Set<Character> alpha = boundedRegexp.getUsedCharacters();
    Hampi h = new Hampi();
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.