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

Examples of pl.edu.amu.wmi.daut.base.NaiveAutomatonSpecification$NaiveTransition


    /**
    * 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 metody createAutomatonFromOneAutomaton
     * z automatem z jednym stanem.
     */
    public final void testCreateAutomatonFromOneAutomaton1() {

        AutomatonSpecification subautomaton = new NaiveAutomatonSpecification();
        State q0 = subautomaton.addState();
        subautomaton.markAsInitial(q0);
        subautomaton.markAsFinal(q0);

        DoNothingOperator operator = new DoNothingOperator();
        NondeterministicAutomatonByThompsonApproach automaton =
                new NondeterministicAutomatonByThompsonApproach(
                operator.createAutomatonFromOneAutomaton(subautomaton));
View Full Code Here

     * Test metody createAutomatonFromOneAutomaton
     * z automatem z kilkoma stanami i przejściami.
     */
    public final void testCreateAutomatonFromOneAutomaton2() {

        AutomatonSpecification subautomaton = new NaiveAutomatonSpecification();
        State q0 = subautomaton.addState();
        State q1 = subautomaton.addState();
        State q2 = subautomaton.addState();
        subautomaton.addTransition(q0, q1, new CharTransitionLabel('a'));
        subautomaton.addLoop(q1, new CharTransitionLabel('b'));
        subautomaton.addTransition(q1, q2, new CharTransitionLabel('a'));
        subautomaton.markAsInitial(q0);
        subautomaton.markAsFinal(q2);

        DoNothingOperator operator = new DoNothingOperator();
        NondeterministicAutomatonByThompsonApproach automaton =
                new NondeterministicAutomatonByThompsonApproach(
                operator.createAutomatonFromOneAutomaton(subautomaton));
View Full Code Here

     * nie zgadza się arność.
     */
    public final void testArityException() {
        RegexpOperator operator = new NullaryRegexpOperator() {
                public AutomatonSpecification createFixedAutomaton() {
                    return new NaiveAutomatonSpecification();
                }
            };

        List<AutomatonSpecification> oneElementList
            = Arrays.<AutomatonSpecification>asList(
                new NaiveAutomatonSpecification());

        boolean thrown = false;
        try {
            operator.createAutomaton(oneElementList);
        } catch (IllegalArgumentException e) {
View Full Code Here

    /**
     * Test metody createAutomatonFromTwoAutomaton.
     */
    public final void testCreateAutomatonFromTwoAutomata() {

        AutomatonSpecification automaton1 = new NaiveAutomatonSpecification();
        State q0 = automaton1.addState();
        State q1 = automaton1.addState();
        automaton1.addTransition(q0, q1, new CharTransitionLabel('a'));
        automaton1.markAsInitial(q0);
        automaton1.markAsFinal(q1);

        AutomatonSpecification automaton2 = new NaiveAutomatonSpecification();
        State q2 = automaton2.addState();
        State q3 = automaton2.addState();
        automaton2.addTransition(q2, q3, new CharTransitionLabel('k'));
        automaton2.markAsInitial(q2);
        automaton2.markAsFinal(q3);

        AnyOrderOperator operator = new AnyOrderOperator();
        NondeterministicAutomatonByThompsonApproach result =
                new NondeterministicAutomatonByThompsonApproach(
                operator.createAutomatonFromTwoAutomata(automaton1, automaton2));

        assertTrue(result.accepts("ak"));
        assertTrue(result.accepts("ka"));
        assertFalse(result.accepts("a"));
        assertFalse(result.accepts("k"));
        assertFalse(result.accepts(""));

        AutomatonSpecification automaton3 = new NaiveAutomatonSpecification();
        State q4 = automaton3.addState();
        State q5 = automaton3.addState();
        automaton3.addTransition(q4, q5, new EpsilonTransitionLabel());
        automaton3.markAsInitial(q4);
        automaton3.markAsFinal(q5);

        AutomatonSpecification automaton4 = new NaiveAutomatonSpecification();
        State q6 = automaton2.addState();
        State q7 = automaton2.addState();
        automaton2.addTransition(q6, q7, new EpsilonTransitionLabel());
        automaton2.markAsInitial(q6);
        automaton2.markAsFinal(q7);
View Full Code Here

TOP

Related Classes of pl.edu.amu.wmi.daut.base.NaiveAutomatonSpecification$NaiveTransition

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.