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

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


    }

    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);
       
View Full Code Here


        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[] {})));
            }
        }
       
View Full Code Here

TOP

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

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.