Package hampi.grammars.apps

Examples of hampi.grammars.apps.GrammarStringBounder


   */
  private Regexp prepareSizeFixRegexp(String cfg, int size, HProgram ast){
    Grammar g = extractGrammar(cfg, ast);
    StopWatch w = new StopWatch("grammar bounding for " + cfg);
    w.start();
    GrammarStringBounder gsb = new GrammarStringBounder();
    Regexp boundedRegexp = gsb.getBoundedRegexp(g, cfg, size, false);
    w.stop();
    System.out.println(w);
    if (boundedRegexp == null)
      throw HampiResultException.unsat();
    return boundedRegexp;
View Full Code Here


import junit.framework.TestCase;

public class BoundingTests extends TestCase{
  public void testMultiCharTerminals() throws Exception{
    Grammar g = new Parser(GrammarTests.DIR + "test_multiCharTerminal.txt").parse();
    GrammarStringBounder gsb = new GrammarStringBounder();
    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "program", 3, false);
    System.out.println(boundedRegexp);
    assertTrue(!boundedRegexp.matches("AB__"));
    assertTrue(boundedRegexp.matches("AB_"));
  }
View Full Code Here

    assertTrue(boundedRegexp.matches("AB_"));
  }

  public void test1() throws Exception{
    Grammar g = new Parser(GrammarTests.DIR + "test_generate_parent.txt").parse();
    GrammarStringBounder gsb = new GrammarStringBounder();
    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "expr", 2, false);
    assertTrue(boundedRegexp.matches("()"));
    assertTrue(!boundedRegexp.matches("(())"));
  }
View Full Code Here

    assertTrue(!boundedRegexp.matches("(())"));
  }

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

    assertNull(boundedRegexp);
  }

  public void test3() throws Exception{
    Grammar g = new Parser(GrammarTests.DIR + "test_generate_parent.txt").parse();
    GrammarStringBounder gsb = new GrammarStringBounder();
    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "expr", 4, false);
    System.out.println(boundedRegexp);
    assertTrue(!boundedRegexp.matches("()"));
    assertTrue(boundedRegexp.matches("(())"));
    assertTrue(boundedRegexp.matches("()()"));
    assertTrue(!boundedRegexp.matches("(((("));
View Full Code Here

  }

  public void test4() throws Exception{
    Grammar g = new Parser(GrammarTests.DIR + "test_generate_parent.txt").parse();
    GrammarStringBounder gsb = new GrammarStringBounder();
    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "expr", 5, false);
    assertNull(boundedRegexp);
  }
View Full Code Here

    assertNull(boundedRegexp);
  }

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

    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

    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

    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

TOP

Related Classes of hampi.grammars.apps.GrammarStringBounder

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.