Package net.sourceforge.chaperon.model.grammar

Examples of net.sourceforge.chaperon.model.grammar.Grammar


    assertEqual(expected, result);
  }

  public void testTest16() throws Exception
  {
    Grammar grammar = getGrammar("net/sourceforge/chaperon/test/parser/test16.xgrm");
    GeneralParserProcessor processor = getGeneralParserProcessor(grammar);
    Document result = process(processor, "net/sourceforge/chaperon/test/parser/test16.in");
    Document expected = getDocument("net/sourceforge/chaperon/test/parser/test16.out");

    assertEqual(expected, result);
View Full Code Here


    assertEqual(expected, result);
  }

  public void testTest17() throws Exception
  {
    Grammar grammar = getGrammar("net/sourceforge/chaperon/test/parser/test17.xgrm");
    GeneralParserProcessor processor = getGeneralParserProcessor(grammar);
    Document result = process(processor, "net/sourceforge/chaperon/test/parser/test17.in");
    Document expected = getDocument("net/sourceforge/chaperon/test/parser/test17.out");

    assertEqual(expected, result);
View Full Code Here

    assertEqual(expected, result);
  }

  public void testTest18() throws Exception
  {
    Grammar grammar = getGrammar("net/sourceforge/chaperon/test/parser/test18.xgrm");
    GeneralParserProcessor processor = getGeneralParserProcessor(grammar);
    Document result = process(processor, "net/sourceforge/chaperon/test/parser/test18.in");
    Document expected = getDocument("net/sourceforge/chaperon/test/parser/test18.out");

    assertEqual(expected, result);
View Full Code Here

    b = new Terminal("b");
    E = new Nonterminal("E");
    F = new Nonterminal("F");
    G = new Nonterminal("G");

    grammar = new Grammar();

    p1 = new Production(F);
    p1.getDefinition().addSymbol(E);
    p1.getDefinition().addSymbol(a);
    p1.getDefinition().addSymbol(E);
View Full Code Here

  public void runTest() throws Throwable
  {
    System.out.println("======================= "+name+" =======================");

    Grammar grammar = getGrammar(step);

    //System.out.println("Grammar:\n"+grammar);
    ParserProcessor processor = getParserProcessor(grammar);

    Document result = null;
View Full Code Here

    GrammarFactory grammarfactory = new GrammarFactory();

    streamer.transform(new DOMSource(node), new SAXResult(grammarfactory));

    Grammar grammar = grammarfactory.getGrammar();

    System.out.println("Grammar:\n"+grammar);

    return grammar;
  }
View Full Code Here

    eof = new EndOfFile();

    S = new Nonterminal("S");
    C = new Nonterminal("C");

    grammar = new Grammar();

    Production production = new Production(S);
    production.getDefinition().addSymbol(C);
    production.getDefinition().addSymbol(C);
    grammar.addProduction(production);
View Full Code Here

    Nonterminal A = new Nonterminal("A");
    Nonterminal B = new Nonterminal("B");
    Nonterminal C = new Nonterminal("C");
    Nonterminal D = new Nonterminal("D");

    grammar = new Grammar();

    Production production = new Production(A);
    production.getDefinition().addSymbol(B);
    production.getDefinition().addSymbol(a);
    grammar.addProduction(production);

    production = new Production(B);
    production.getDefinition().addSymbol(b);
    grammar.addProduction(production);

    production = new Production(C);
    production.getDefinition().addSymbol(B);
    production.getDefinition().addSymbol(D);
    grammar.addProduction(production);

    production = new Production(D);

    // empty
    grammar.addProduction(production);

    firstsets = new FirstSetCollection(grammar);

    set = new ItemSet(grammar, firstsets);
    set.addItem(0, 0, c);

    result = new ItemSet(grammar, firstsets);
    result.addItem(0, 0, c);
    result.addItem(1, 0, a);

    assertEquals("Test if sets are equal", result, set.closure());

    set = new ItemSet(grammar, firstsets);
    set.addItem(2, 0, a);

    result = new ItemSet(grammar, firstsets);
    result.addItem(2, 0, a);
    result.addItem(1, 0, a);

    assertEquals("Test if sets are equal", result, set.closure());

    // ---- Case 3 ----
    grammar = new Grammar();

    production = new Production(A);
    production.getDefinition().addSymbol(B);
    production.getDefinition().addSymbol(D);
    grammar.addProduction(production);
View Full Code Here

    Eprime = new Nonterminal("E'");
    T = new Nonterminal("T");
    Tprime = new Nonterminal("T'");
    F = new Nonterminal("F");

    grammar = new Grammar();

    // E -> T E'
    Production production = new Production(E);
    production.getDefinition().addSymbol(T);
    production.getDefinition().addSymbol(Eprime);
View Full Code Here

        GrammarFactory factory = new GrammarFactory();
        SourceUtil.toSAX(this.manager, this.grammarSource, null, factory);

        //Configuration config = confighandler.getConfiguration();
        //Grammar grammar = GrammarFactory.createGrammar(config);
        Grammar grammar = factory.getGrammar();

        if (grammar==null)
          throw new ProcessingException("Error while reading the grammar from "+src);

        ParserAutomatonBuilder builder =
View Full Code Here

TOP

Related Classes of net.sourceforge.chaperon.model.grammar.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.