Package hampi.grammars.parser

Examples of hampi.grammars.parser.Parser


  public void test9() throws Exception{
    defaultTest(9);
  }

  private void defaultTest(int num) throws IOException{
    Grammar g = new Parser(DIR + "test_epsilons" + num + ".txt").parse();
    new EpsilonProductionRemover().removeEpsilonProductions(g, "S");
    compareIgnoreNewlines(g.toString(), DIR + "test_epsilons" + num + "_expected.txt");
    Set<GrammarProduction> epsilonProductions = EpsilonProductionRemover.getEpsilonProductions(g, g.getNonterminal("S"));
    assertTrue(epsilonProductions.isEmpty());
  }
View Full Code Here


    Set<GrammarProduction> epsilonProductions = EpsilonProductionRemover.getEpsilonProductions(g, g.getNonterminal("S"));
    assertTrue(epsilonProductions.isEmpty());
  }

  public void testDups() throws Exception{
    Grammar g = new Parser(DIR + "test_dups.txt").parse();
    new EpsilonProductionRemover().removeEpsilonProductions(g, "S");
    Set<GrammarProduction> epsilonProductions = EpsilonProductionRemover.getEpsilonProductions(g, g.getNonterminal("S"));
    assertTrue(epsilonProductions.isEmpty());
  }
View Full Code Here

    Set<GrammarProduction> epsilonProductions = EpsilonProductionRemover.getEpsilonProductions(g, g.getNonterminal("S"));
    assertTrue(epsilonProductions.isEmpty());
  }

  public void testECMA() throws Exception{
    Grammar g = new Parser(DIR + "ecmascript.txt").parse();
    new EpsilonProductionRemover().removeEpsilonProductions(g, "FunctionDeclaration");
    Set<GrammarProduction> epsilonProductions = EpsilonProductionRemover.getEpsilonProductions(g, g.getNonterminal("FunctionDeclaration"));
    assertTrue(epsilonProductions.isEmpty());
  }
View Full Code Here

import junit.framework.TestCase;

public class CYKTests extends TestCase{
  public void test1() throws Exception{
    String grammarFile = "tests/resources/test_cyk1.txt";
    Grammar g = new Parser(grammarFile).parse();
    System.out.println(g);
    CYKParser p = new CYKParser(g);
    List<ParseTree> parse = p.parse("s1 s2".split(" "), "S");
    assertTrue(!parse.isEmpty());
  }
View Full Code Here

    assertTrue(!parse.isEmpty());
  }

  public void test2() throws Exception{
    String grammarFile = "tests/resources/test_cyk1.txt";
    Grammar g = new Parser(grammarFile).parse();
    System.out.println(g);
    CYKParser p = new CYKParser(g);
    List<ParseTree> parse = p.parse("s1 s2 s1".split(" "), "S");
    assertTrue(parse.isEmpty());
  }
View Full Code Here

    assertTrue(parse.isEmpty());
  }

  public void test3() throws Exception{
    String grammarFile = "tests/resources/test_cyk2.txt";
    Grammar g = new Parser(grammarFile).parse();
    System.out.println(g);
    CYKParser p = new CYKParser(g);
    String s = "b a a b a";
    List<ParseTree> parse = p.parse(s.split(" "), "S");
    System.out.println(s);
View Full Code Here

    assertTrue(!parse.isEmpty());
  }

  public void test4() throws Exception{
    String grammarFile = "tests/resources/test_cyk2.txt";
    Grammar g = new Parser(grammarFile).parse();
    System.out.println(g);
    CYKParser p = new CYKParser(g);
    String s = "b a b a";
    List<ParseTree> parse = p.parse(s.split(" "), "S");
    assertTrue(parse.toString(), parse.isEmpty());
View Full Code Here

    assertTrue(parse.toString(), parse.isEmpty());
  }

  public void test5() throws Exception{
    String grammarFile = "tests/resources/test_cyk3.txt";
    Grammar g = new Parser(grammarFile).parse();
    System.out.println(g);
    CYKParser p = new CYKParser(g);
    String s = "a b b d a b";
    List<ParseTree> parse = p.parse(s.split(" "), "S");
    assertTrue(!parse.isEmpty());
View Full Code Here

    assertTrue(!parse.isEmpty());
  }

  public void test6() throws Exception{
    String grammarFile = "tests/resources/test_cyk3.txt";
    Grammar g = new Parser(grammarFile).parse();
    System.out.println(g);
    CYKParser p = new CYKParser(g);
    String s = "b a d";
    List<ParseTree> parse = p.parse(s.split(" "), "S");
    assertTrue(parse.toString(), parse.isEmpty());
View Full Code Here

    assertTrue(parse.toString(), parse.isEmpty());
  }

  public void testEcmascript1() throws Exception{
    String grammarFile = "tests/resources/ecmascript.txt";
    Grammar g = new Parser(grammarFile).parse();
    assertTrue(!g.isCNF());

    List<Grammar> steps = new ArrayList<Grammar>();
    final String startSymbol = "FunctionDeclaration";
    Grammar gCNF = new CNFConverter().convertToCNF(g, startSymbol, steps);
View Full Code Here

TOP

Related Classes of hampi.grammars.parser.Parser

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.