Package eas.math.fundamentalAlgorithms.graphBased.algorithms.type0grammars

Examples of eas.math.fundamentalAlgorithms.graphBased.algorithms.type0grammars.Nonterminal


        if (dia.getDirectory() == null || dia.getFile() == null) {
            env.getSimTime().timeTerminate();
            System.exit(0);
        }
       
        grammar = new Grammar(new File(dia.getDirectory() + File.separator + dia.getFile()), new Nonterminal(new StringBuffer("S")));
       
        env.addAgent(
                new GrammarAgent(
                        env.getFirstFreeID(),
                        env,
View Full Code Here


    public static void main(String[] args) {
        eas.math.fundamentalAlgorithms.graphBased.algorithms.type0grammars.Grammar g = new eas.math.fundamentalAlgorithms.graphBased.algorithms.type0grammars.Grammar();
       
        g.addRule(new Rule(
                new Word(new Symbol[] {new Nonterminal(new StringBuffer("S"))}),
                new Word(new Symbol[] {
                        new Nonterminal(new StringBuffer("a")),
                        new Nonterminal(new StringBuffer("S")),
                        new Terminal(new StringBuffer("b"))})));

        g.addRule(new Rule(
                new Word(new Symbol[] {new Nonterminal(new StringBuffer("S"))}),
                new Word(new Symbol[] {
                        new Nonterminal(new StringBuffer("S")),
                        new Terminal(new StringBuffer("S"))})));

        g.addRule(new Rule(
                new Word(new Symbol[] {new Nonterminal(new StringBuffer("S"))}),
                new Word(new Symbol[] {new Terminal(new StringBuffer("a")), new Terminal(new StringBuffer("b"))})));

        CtxtFreeGrammar g2 = new CtxtFreeGrammar(g);
       
        try {
View Full Code Here

       
        return "";
    }

    public Grammar generateType3Grammar() {
        Grammar g = new Grammar(new Nonterminal(new StringBuffer(this.initialState)));

        LinkedList<String> reachableStates = new LinkedList<>(this.getAllReachableStates());
       
        Collections.sort(reachableStates);
       
        for (String fromState : reachableStates) {
            for (Transition targetTransition : this.getTransitionsFrom(fromState)) {
                String toState = targetTransition.getDestination();
                String symbol = targetTransition.getLabel();
               
                g.addRule(new Rule(
                        new Word(new Symbol[] {new Nonterminal(new StringBuffer(fromState))}),
                        new Word(new Symbol[] {
                                new Terminal(new StringBuffer(symbol)),
                                new Nonterminal(new StringBuffer(toState))})));
            }
           
            if (this.finalStates.contains(fromState)) {
                g.addRule(new Rule(
                        new Word(new Symbol[] {new Nonterminal(new StringBuffer(fromState))}),
                        new Word(new Symbol[] {})));
            }
        }
       
        return g;
View Full Code Here

TOP

Related Classes of eas.math.fundamentalAlgorithms.graphBased.algorithms.type0grammars.Nonterminal

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.