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

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


    public CharClassOperator(String c) {
        this.charClass = c;
    }
    @Override
    public AutomatonSpecification createFixedAutomaton() {
        AutomatonSpecification automaton = new NaiveAutomatonSpecification();
        State q0 = automaton.addState();
        State q1 = automaton.addState();
        automaton.addTransition(q0, q1,
            new CharClassTransitionLabel(charClass));
        automaton.markAsInitial(q0);
        automaton.markAsFinal(q1);

        return automaton;
    }
View Full Code Here


public class WhitespaceOperator extends NullaryRegexpOperator {
    private static final String WHITESPACE_CHARS = "\t\n\f\r \u000B";

    @Override
    public AutomatonSpecification createFixedAutomaton() {
        AutomatonSpecification automaton = new NaiveAutomatonSpecification();
        State q0 = automaton.addState();
        State q1 = automaton.addState();
        automaton.markAsInitial(q0);
        automaton.markAsFinal(q1);
        automaton.addTransition(q0, q1, new CharClassTransitionLabel(WHITESPACE_CHARS));
        return automaton;
    }
View Full Code Here

     * Główna metoda klasy.
     */
    @Override
    public AutomatonSpecification createFixedAutomaton() {

        AutomatonSpecification automaton = new NaiveAutomatonSpecification();
        char a = '0';
        char b = '9';
        State q0 = automaton.addState();
        State q1 = automaton.addState();
        automaton.addTransition(q0, q1, new CharRangeTransitionLabel(a, b));
        automaton.markAsInitial(q0);
        automaton.markAsFinal(q1);

        return automaton;
    }
View Full Code Here

    private String s;

    @Override
    public AutomatonSpecification createFixedAutomaton() {
      AutomatonSpecification automaton = new NaiveAutomatonSpecification();
      automaton.markAsInitial(automaton.addState());
      automaton.markAsFinal(automaton.addTransitionSequence(automaton.getInitialState(), this.s));
      return automaton;
    }
View Full Code Here

    /**
     * Generuje automat.
     */
    @Override
    public AutomatonSpecification createFixedAutomaton() {
        AutomatonSpecification automaton = new NaiveAutomatonSpecification();
        State q0 = automaton.addState();
        State q1 = automaton.addState();
        automaton.markAsInitial(q0);
        automaton.markAsFinal(q1);

        automaton.addTransition(q0, q1, new ComplementCharClassTransitionLabel(str));

        return automaton;
    }
View Full Code Here

    /**
     * Test createFixedAutomaton.
     */
    public void testcreateFixedAutomaton() {
         NoWhitespaceOperator operator = new NoWhitespaceOperator();
         AutomatonSpecification spec = operator.createFixedAutomaton();
         assertFalse(spec.isEmpty());
         assertFalse(spec.acceptEmptyWord());
         AutomatonByRecursion automaton = new AutomatonByRecursion(spec);

         assertFalse(automaton.accepts(" "));
         assertFalse(automaton.accepts("\n"));
         assertFalse(automaton.accepts("\t"));
View Full Code Here

    /**
     * Test znaku ucieczki "\a".
     */
    public void testEscapeOperatorA() {
        EscapeOperator operator = new EscapeOperator('a');
        AutomatonSpecification automaton = operator.createFixedAutomaton();
        NondeterministicAutomatonByThompsonApproach result =
                new NondeterministicAutomatonByThompsonApproach(automaton);

        assertFalse(automaton.isEmpty());
        assertTrue(result.accepts("\7"));
        assertFalse(result.accepts("\\7"));
        assertFalse(result.accepts("\6"));
        assertFalse(result.accepts("c"));
    }
View Full Code Here

     * Test znaku ucieczki "\n".
     */
    public void testEscapeOperatorN() {

        EscapeOperator operator1 = new EscapeOperator('n');
        AutomatonSpecification automaton1 = operator1.createFixedAutomaton();
        NondeterministicAutomatonByThompsonApproach result1 =
                new NondeterministicAutomatonByThompsonApproach(automaton1);

        assertFalse(automaton1.isEmpty());
        assertTrue(result1.accepts("\n"));
        assertFalse(result1.accepts("\\nn"));
        assertFalse(result1.accepts("n"));

    }
View Full Code Here

     * Test znaku ucieczki "\t".
     */
    public void testEscapeOperatorT() {

        EscapeOperator operator2 = new EscapeOperator('t');
        AutomatonSpecification automaton2 = operator2.createFixedAutomaton();
        NondeterministicAutomatonByThompsonApproach result2 =
                new NondeterministicAutomatonByThompsonApproach(automaton2);

        assertFalse(automaton2.isEmpty());
        assertTrue(result2.accepts("\t"));
        assertFalse(result2.accepts("\\tt"));
        assertFalse(result2.accepts("t"));
    }
View Full Code Here

     * Test znaku ucieczki "\f".
     */
    public void testEscapeOperatorF() {

        EscapeOperator operator3 = new EscapeOperator('f');
        AutomatonSpecification automaton3 = operator3.createFixedAutomaton();
        NondeterministicAutomatonByThompsonApproach result3 =
                new NondeterministicAutomatonByThompsonApproach(automaton3);

        assertFalse(automaton3.isEmpty());
        assertTrue(result3.accepts("\f"));
        assertFalse(result3.accepts("\\ff"));
        assertFalse(result3.accepts("f"));
    }
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.