Package hampi.grammars.parser

Examples of hampi.grammars.parser.Parser


    assertTrue("cannot parse: " + s, !parse.isEmpty());
  }

  public void testEcmascript2() throws Exception{
    String grammarFile = "tests/resources/test_cyk_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


    assertTrue("cannot parse: " + s, !parse.isEmpty());
  }

  public void testEcmascript3() throws Exception{
    String grammarFile = "tests/resources/test_cyk_ecmascript1.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

    assertTrue("cannot parse: " + s, !parse.isEmpty());
  }

  public void testEcmascript4() 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

    assertTrue("cannot parse: " + s, !parse.isEmpty());
  }

  public void testEcmascript5() 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 = "Statement";
    Grammar gCNF = new CNFConverter().convertToCNF(g, startSymbol, steps);
View Full Code Here

    assertTrue("cannot parse: " + s, !parse.isEmpty());
  }

  public void testEcmascript6() 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 = "Expression";
    Grammar gCNF = new CNFConverter().convertToCNF(g, startSymbol, steps);
View Full Code Here

    assertTrue("cannot parse: " + s, !parse.isEmpty());
  }

  public void testEcmascript7() 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 = "AssignmentExpression";
    Grammar gCNF = new CNFConverter().convertToCNF(g, startSymbol, steps);
View Full Code Here

    assertTrue("cannot parse: " + s, !parse.isEmpty());
  }

  public void testEcmascript8() 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 = "AssignmentExpression";
    Grammar gCNF = new CNFConverter().convertToCNF(g, startSymbol, steps);
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__"));
    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("()"));
    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

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.