Package net.sourceforge.chaperon.model.grammar

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


    // Create a grammar model for a given grammar file
    GrammarFactory grammarfactory = new GrammarFactory();
    xmlparser.setContentHandler(grammarfactory);
    xmlparser.parse(grammarFile.toString());

    Grammar grammar = grammarfactory.getGrammar();

    // Build a automaton from the grammar model
    ParserAutomaton parserautomaton =
      (new ParserAutomatonBuilder(grammar, log)).getParserAutomaton();
View Full Code Here


    E = new Nonterminal("E");
    T = new Nonterminal("T");
    F = new Nonterminal("F");

    grammar = new Grammar();

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

    GrammarFactory handler = new GrammarFactory();
    parser.setContentHandler(handler);
    parser.parse(new InputSource(getClass().getResourceAsStream("java.xgrm")));

    Grammar grammar = handler.getGrammar();

    Automaton collection = new Automaton(grammar,  /*firstsets,*/
                                         null);

    System.out.println(collection);
View Full Code Here

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

    grammar = new Grammar();

    grammar.setStartSymbol(E);

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

    super(name);
  }

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

    assertEqual(expected, result);
View Full Code Here

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

    assertEqual(expected, result);
View Full Code Here

    assertEqual(expected, result);
  }

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

    assertEqual(expected, result);
View Full Code Here

    assertEqual(expected, result);
  }

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

    assertEqual(expected, result);
View Full Code Here

    assertEqual(expected, result);
  }*/
/* Endless loop*/
  public void testTest13() throws Exception
  {
    Grammar grammar = getGrammar("net/sourceforge/chaperon/test/parser/test13.xgrm");
    GeneralParserProcessor processor = getGeneralParserProcessor(grammar);
    Document result = process(processor, "net/sourceforge/chaperon/test/parser/test13.in");
    Document expected = getDocument("net/sourceforge/chaperon/test/parser/test13.out");

    assertEqual(expected, result);
View Full Code Here

    assertEqual(expected, result);
  }

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

    assertEqual(expected, result);
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.