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

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


     *     postaci {(ab)^n : n>0}
     * automaton2 - automatu pustego.
     */
    public final void testCreateAutomatonFromTwoAutomata2() {

        AutomatonSpecification automaton1 = new NaiveAutomatonSpecification();

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

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

        AutomatonSpecification automaton2 = new NaiveAutomatonSpecification();

        AlternativeOperator oper = new AlternativeOperator();
        NondeterministicAutomatonByThompsonApproach result =
        new NondeterministicAutomatonByThompsonApproach(
                oper.createAutomatonFromTwoAutomata(automaton1, automaton2));
View Full Code Here


     * Test metody createFixedAutomaton.
     */
    public void testCreateFixedAutomaton() {

        WhitespaceOperator operator = new WhitespaceOperator();
        AutomatonSpecification spec = operator.createFixedAutomaton();
        assertFalse(spec.isEmpty());
        assertFalse(spec.acceptEmptyWord());
        AutomatonByRecursion automaton = new AutomatonByRecursion(spec);
        assertTrue(automaton.accepts("\t"));
        assertTrue(automaton.accepts("\n"));
        assertTrue(automaton.accepts("\f"));
        assertTrue(automaton.accepts("\r"));
View Full Code Here

    /**
* Test metody createAutomatonFromOneAutomaton.
*/
    public final void testCreateAutomatonFromOneAutomaton() {

        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('b'));
        automaton.addLoop(q1, new CharTransitionLabel('a'));
        automaton.addLoop(q2, new CharTransitionLabel('b'));

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

        OptionalityOperator operator = new OptionalityOperator();
        NondeterministicAutomatonByThompsonApproach result =
            new NondeterministicAutomatonByThompsonApproach(
                operator.createAutomatonFromOneAutomaton(automaton));

        assertTrue(result.accepts("aaabbb"));
        assertTrue(result.accepts("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbb"));
        assertTrue(result.accepts("aabbbbbbbbbbbbb"));
        assertTrue(result.accepts("ab"));
        assertTrue(automaton.acceptEmptyWord());

        assertFalse(result.accepts("aaabbbbaabbbbab"));
        assertFalse(result.accepts("aaaaaaaaaaa"));
        assertFalse(result.accepts("cojapacze"));
        assertFalse(result.accepts("macrimnatueshzanc"));
View Full Code Here

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

        NewLineOperator operator = new NewLineOperator();
        AutomatonSpecification spec = operator.createFixedAutomaton();
        assertFalse(spec.isEmpty());
        assertFalse(spec.acceptEmptyWord());

        AutomatonByRecursion automaton = new AutomatonByRecursion(spec);
        assertTrue(automaton.accepts("\n"));
        assertFalse(automaton.accepts("a"));
        assertFalse(automaton.accepts("%"));
View Full Code Here

     * Test metody createFixedAutomaton.
     */
    public void testCreateFixedAutomaton() {

        DigitOperator operator = new DigitOperator();
        AutomatonSpecification spec = operator.createFixedAutomaton();
        assertFalse(spec.isEmpty());
        assertFalse(spec.acceptEmptyWord());

        AutomatonByRecursion automaton = new AutomatonByRecursion(spec);
        assertTrue(automaton.accepts("0"));
        assertTrue(automaton.accepts("9"));
        assertTrue(automaton.accepts("1"));
View Full Code Here

    /**
     * Test metody createAutomatonFromOneAutomaton.
     */
    public final void testCreateAutomatonFromOneAutomaton() {

        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('b'));
        automaton.addLoop(q1, new CharTransitionLabel('a'));
        automaton.addLoop(q2, new CharTransitionLabel('b'));

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

        AtLeastOneOperator operator = new AtLeastOneOperator();
        NondeterministicAutomatonByThompsonApproach result =
        new NondeterministicAutomatonByThompsonApproach(
                operator.createAutomatonFromOneAutomaton(automaton));

        assertTrue(result.accepts("aaaab"));
        assertTrue(result.accepts("abbbbb"));
        assertTrue(result.accepts("aaaaaaaaaaaabb"));
        assertTrue(result.accepts("abbbaaaab"));
        assertTrue(result.accepts("abababb"));

        assertFalse(automaton.acceptEmptyWord());
        assertFalse(result.accepts("baba"));
        assertFalse(result.accepts("baaaaaaaaa"));
        assertFalse(result.accepts("cojatestujem"));
        assertFalse(result.accepts("bartlomiejburczymucha"));
    }
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.