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

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


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

        AutomatonSpecification automaton = new NaiveAutomatonSpecification();

        MinimumNumberOfOccurencesOperator oper =
            new MinimumNumberOfOccurencesOperator(10);

        NondeterministicAutomatonByThompsonApproach result =
View Full Code Here


     * Stany te są stanami akceptującymi.
     */

    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);

        MinimumNumberOfOccurencesOperator oper =
            new MinimumNumberOfOccurencesOperator(3);

        NondeterministicAutomatonByThompsonApproach result =
View Full Code Here

     * Konstruuje automat, a nastepnie go testuje.
     */
    public final void testAutomaton() {

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

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

     */

    public void testCreateFixedAutomaton() {

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

        AutomatonByRecursion automaton = new AutomatonByRecursion(spec);
        assertTrue(automaton.accepts("\13"));
        assertFalse(automaton.accepts("a"));
        assertFalse(automaton.accepts("%"));
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

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

        SingleCharacterOperator operator = new SingleCharacterOperator('c');
        AutomatonSpecification automaton = operator.createFixedAutomaton();
        NondeterministicAutomatonByThompsonApproach result =
          new NondeterministicAutomatonByThompsonApproach(automaton);

        assertFalse(automaton.isEmpty());

        assertTrue(result.accepts("c"));

        assertFalse(result.accepts("cc"));
        assertFalse(result.accepts("a"));
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

     * Konstruuje przykładowy automat, a następnie go testuje.
     */
    public void testAutomaton() {

        BellCharacterOperator operator = new BellCharacterOperator();
        AutomatonSpecification aut = operator.createFixedAutomaton();
        NondeterministicAutomatonByThompsonApproach a
            = new NondeterministicAutomatonByThompsonApproach(aut);

        assertTrue(a.accepts(Character.toString('\7')));
        assertFalse(a.accepts(Character.toString('8')));
View Full Code Here

     * automaton2 - akceptującego wyraz składający się z liter "a" i "b",
     *     który zawiera nieparzystą ilość "b".
     */
    public final void testCreateAutomatonFromTwoAutomata1() {

        AutomatonSpecification automaton1 = new NaiveAutomatonSpecification();

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

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

        AutomatonSpecification automaton2 = new NaiveAutomatonSpecification();

        State q2 = automaton2.addState();
        State q3 = automaton2.addState();
        automaton2.addTransition(q2, q3, new CharTransitionLabel('b'));
        automaton2.addTransition(q3, q2, new CharTransitionLabel('b'));
        automaton2.addLoop(q2, new CharTransitionLabel('a'));
        automaton2.addLoop(q3, new CharTransitionLabel('a'));

        automaton2.markAsInitial(q2);
        automaton2.markAsFinal(q3);

        AlternativeOperator oper = new AlternativeOperator();
        NondeterministicAutomatonByThompsonApproach result =
        new NondeterministicAutomatonByThompsonApproach(
                oper.createAutomatonFromTwoAutomata(automaton1, automaton2));
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.