Examples of Grammar


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

  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

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

    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

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

    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

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

    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

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

    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

Examples of opennlp.ccg.grammar.Grammar

 
  @Before
  @SuppressWarnings("deprecation")
  public void setUp() throws Exception {
    if(grammar == null) {
      grammar = new Grammar(new File(new File(
          new File(System.getProperty("user.dir")), "test"),
          "grammar.xml").toURL());
    }
  }
View Full Code Here

Examples of org.allspice.parser.Grammar

   * @throws StrandedSymbol
   * @throws InvalidStartRule
   */
  private static AugmentedParseTable createParseTable() throws StateConflict, InvalidStartRule, StrandedSymbol {
    DefaultTranslationMapper mapper = createMapper() ;
    Grammar g = new Grammar("E'",mapper.rules.keySet(),
        new Tree23Map<String,AssocType>(),
        new Tree23Map<String,Integer>(),
        new Tree23Map<Rule,Integer>()) ;
    return new AugmentedParseTableImpl(mapper,ParserGenerator.createParseTable(g));
  }
View Full Code Here

Examples of org.antlr.tool.Grammar

    }

    public String getGrammarLanguage() {
        try {
            antlrEngine.createGrammars();
            Grammar g = antlrEngine.getParserGrammar();
            if(g == null) {
                g = antlrEngine.getLexerGrammar();
            }
            if(g != null) {
                return (String)g.getOption("language");
            }
        } catch (Exception e) {
            delegate.reportError(e);
        }
        return null;
View Full Code Here

Examples of org.antlr.tool.Grammar

    public String getGeneratedClassName(int type) throws Exception {
        String name = null;
        antlrEngine.createGrammars();
        if(type == ElementGrammarName.LEXER) {
            Grammar g = antlrEngine.getLexerGrammar();
            if(g == null) return null;
            name = g.name+getSuffix(type);
        } else if(type == ElementGrammarName.PARSER) {
            Grammar g = antlrEngine.getParserGrammar();
            if(g == null) return null;
            name = g.name+getSuffix(type);
        } else if(type == ElementGrammarName.TREEPARSER) {
            Grammar g = antlrEngine.getParserGrammar();
            if(g == null) return null;
            if(!isTreeParserGrammar()) return null;
            name = g.name+getSuffix(type);
        }
        return name;
View Full Code Here

Examples of org.antlr.tool.Grammar

        }
    }

    public List<String> getAllGeneratedNames() throws Exception {
        List<String> names = new ArrayList<String>();
        Grammar g = antlrEngine.getDefaultGrammar();
        if(g != null) {
            names.add(g.getRecognizerName());
            for(Grammar gd : g.getDelegates()) {
                names.add(gd.getRecognizerName());
            }
        }

        Grammar lexer = antlrEngine.getLexerGrammar();
        if(lexer != null) {
            names.add(lexer.getRecognizerName());
            for(Grammar gd : lexer.getDelegates()) {
                names.add(gd.getRecognizerName());
            }
        }
        return names;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.