Package pl.edu.amu.wmi.daut.base

Examples of pl.edu.amu.wmi.daut.base.AutomatonSpecification


        subtrees.add(subtree10);
        subtrees.add(subtree11);
        RegexpOperatorTree tree = new RegexpOperatorTree(root, subtrees);

        //Tworzymy automat dla tego drzewa.
        AutomatonSpecification automaton =
                RegexpUtilities.createAutomatonFromOperatorTree(tree);
        NondeterministicAutomatonByThompsonApproach result =
                new NondeterministicAutomatonByThompsonApproach(automaton);

        //Testujemy.
View Full Code Here


    /**
    * Test 1. Automat z jednym przejściem na dwóch stanach.
    */
    public final void testTwoStatesOneTransitionLabel() {

        AutomatonSpecification automaton = new NaiveAutomatonSpecification();

        State q0 = automaton.addState();
        State q1 = automaton.addState();
        automaton.addTransition(q0, q1, new CharTransitionLabel('a'));

        automaton.markAsInitial(q0);
        automaton.markAsFinal(q1);

        FixedNumberOfOccurrencesOperator oper =
                new FixedNumberOfOccurrencesOperator(4);

        NondeterministicAutomatonByThompsonApproach result =
View Full Code Here

    /**
    * Test 2. Automat akceptuje słowa a(b^n)a(d^n)b oraz (a^n)c(d^n)b.
    */
    public final void testExemplaryAutomaton() {

        AutomatonSpecification automaton = new NaiveAutomatonSpecification();

        State q0 = automaton.addState();
        State q1 = automaton.addState();
        State q2 = automaton.addState();
        State q3 = automaton.addState();
        State q4 = automaton.addState();
        automaton.addTransition(q0, q1, new CharTransitionLabel('a'));
        automaton.addTransition(q1, q2, new CharTransitionLabel('a'));
        automaton.addTransition(q0, q3, new CharTransitionLabel('a'));
        automaton.addTransition(q3, q2, new CharTransitionLabel('c'));
        automaton.addTransition(q2, q4, new CharTransitionLabel('b'));
        automaton.addLoop(q1, new CharTransitionLabel('b'));
        automaton.addLoop(q2, new CharTransitionLabel('d'));
        automaton.addLoop(q3, new CharTransitionLabel('a'));


        automaton.markAsInitial(q0);
        automaton.markAsFinal(q4);

        FixedNumberOfOccurrencesOperator oper =
                new FixedNumberOfOccurrencesOperator(2);

        NondeterministicAutomatonByThompsonApproach result =
View Full Code Here

    /**
    * Test 3. Pusty automat.
    */
    public final void testEmptyAutomaton() {

          AutomatonSpecification automaton = new NaiveAutomatonSpecification();

          FixedNumberOfOccurrencesOperator oper =
                new FixedNumberOfOccurrencesOperator(666);

          NondeterministicAutomatonByThompsonApproach result =
View Full Code Here

    * przejścia do stanu do stanu q1 poprzez 'a' i do stanu q2 poprzez 'b'.
    * Stany q1 i q1 są stanami akceptowalnymi.
    */
    public final void testThreeStatesTwoFinalStates() {

        AutomatonSpecification automaton = new NaiveAutomatonSpecification();

        State q0 = automaton.addState();
        State q1 = automaton.addState();
        State q2 = automaton.addState();
        automaton.addTransition(q0, q1, new CharTransitionLabel('a'));
        automaton.addTransition(q0, q2, new CharTransitionLabel('b'));

        automaton.markAsInitial(q0);
        automaton.markAsFinal(q1);
        automaton.markAsFinal(q2);

        FixedNumberOfOccurrencesOperator oper =
                new FixedNumberOfOccurrencesOperator(3);

        NondeterministicAutomatonByThompsonApproach result =
View Full Code Here

    /**
    * Test 5. Mnożnik n=0.
    */
    public final void testMultiplierEqualsZero() {
        AutomatonSpecification automaton = new NaiveAutomatonSpecification();

        State q0 = automaton.addState();
        State q1 = automaton.addState();
        automaton.addTransition(q0, q1, new CharTransitionLabel('x'));

        automaton.markAsInitial(q0);
        automaton.markAsFinal(q1);

        FixedNumberOfOccurrencesOperator oper =
                new FixedNumberOfOccurrencesOperator(0);

        NondeterministicAutomatonByThompsonApproach result =
View Full Code Here

     * Drugi akceptuje słowa z dokładnie dwoma "c" i dowolną ilością "a".
     * Powstały ma akceptować ich konkatenację.
     */
    public final void testCreateAutomatonFromTwoAutomata() {

        AutomatonSpecification a1 = new NaiveAutomatonSpecification();

        State q0 = a1.addState();
        State q1 = a1.addState();
        a1.addTransition(q0, q1, new CharTransitionLabel('b'));
        a1.addLoop(q0, new CharTransitionLabel('a'));
        a1.addLoop(q1, new CharTransitionLabel('b'));
        a1.addLoop(q1, new CharTransitionLabel('a'));

        a1.markAsInitial(q0);
        a1.markAsFinal(q1);

        AutomatonSpecification a2 = new NaiveAutomatonSpecification();

        State q0c = a2.addState();
        State q1c = a2.addState();
        State q2c = a2.addState();
        a2.addTransition(q0c, q1c, new CharTransitionLabel('c'));
        a2.addTransition(q1c, q2c, new CharTransitionLabel('c'));
        a2.addLoop(q0c, new CharTransitionLabel('a'));
        a2.addLoop(q1c, new CharTransitionLabel('a'));
        a2.addLoop(q2c, new CharTransitionLabel('a'));

        a2.markAsInitial(q0c);
        a2.markAsFinal(q2c);

        ConcatenationOperator con = new ConcatenationOperator();
        NondeterministicAutomatonByThompsonApproach result =
        new NondeterministicAutomatonByThompsonApproach(
                con.createAutomatonFromTwoAutomata(a1, a2));
View Full Code Here

     * Test CreateFixedAutomaton.
     */
    public final void testCreateFixedAutomaton() {

        OctSingleCharacterOperator operator = new OctSingleCharacterOperator(120);
        AutomatonSpecification automaton = operator.createFixedAutomaton();
        NondeterministicAutomatonByThompsonApproach result =
                new NondeterministicAutomatonByThompsonApproach(automaton);

        assertFalse(automaton.isEmpty());

        assertTrue(result.accepts("P"));
        assertFalse(result.accepts("PP"));
        assertFalse(result.accepts(" P"));
        assertFalse(result.accepts("cc"));
View Full Code Here

    /**
     * Automat z jednym przejściem na dwóch stanach.
     */
    public final void testTwoStatesOneTransitionLabel() {

        AutomatonSpecification automaton = new NaiveAutomatonSpecification();

        State q0 = automaton.addState();
        State q1 = automaton.addState();
        automaton.addTransition(q0, q1, new CharTransitionLabel('a'));

        automaton.markAsInitial(q0);
        automaton.markAsFinal(q1);

        MinimumNumberOfOccurencesOperator oper =
                new MinimumNumberOfOccurencesOperator(3);

        NondeterministicAutomatonByThompsonApproach result =
View Full Code Here

    /**
     * Automat akceptuje słowa a(b^n)a.
     */
    public final void testExemplaryAutomaton() {

        AutomatonSpecification automaton = new NaiveAutomatonSpecification();

        State q0 = automaton.addState();
        State q1 = automaton.addState();
        State q2 = automaton.addState();
        automaton.addTransition(q0, q1, new CharTransitionLabel('a'));
        automaton.addTransition(q1, q2, new CharTransitionLabel('a'));
        automaton.addLoop(q1, new CharTransitionLabel('b'));


        automaton.markAsInitial(q0);
        automaton.markAsFinal(q2);

        MinimumNumberOfOccurencesOperator oper =
                new MinimumNumberOfOccurencesOperator(2);

        NondeterministicAutomatonByThompsonApproach result =
View Full Code Here

TOP

Related Classes of pl.edu.amu.wmi.daut.base.AutomatonSpecification

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.