Package dk.brics.automaton

Examples of dk.brics.automaton.State


        for (State s : b.getStates()) {
            Set<Transition> transitions = s.getTransitions();
            for (Transition t : new ArrayList<Transition>(transitions)) {
                char min = t.getMin();
                char max = t.getMax();
                State dest = t.getDest();
                if (min != Character.MIN_VALUE || max != Character.MAX_VALUE) {
                    transitions.remove(t);
                    for (int c = min; c <= max; c++) {
                        transitions.add(new Transition(Character.toLowerCase((char) c), dest));
                    }
View Full Code Here


        Map<State, Set<State>> special_prevs = new HashMap<State, Set<State>>();
        findPrevs(b, normal_prevs, special_prevs);
        Set<State> pre = findPreSet(b);
        Set<State> post = findPostSet(b, special_prevs);
        boolean initial_accept = post.contains(b.getInitialState());
        State initial = new State();
        b.setInitialState(initial);
        for (State s : pre) {
            for (Transition t : new ArrayList<Transition>(s.getTransitions())) {
                char min = t.getMin();
                char max = t.getMax();
                if (min <= '\u0020') {
                    min = '\u0021';
                }
                if (min <= max) {
                    initial.addTransition(new Transition(min, max, t.getDest()));
                }
            }
        }
        State accept = new State();
        accept.setAccept(true);
        for (State s : b.getAcceptStates()) {
            s.setAccept(false);
        }
        if (initial_accept) {
            initial.setAccept(true);
View Full Code Here

    private Set<State> findPreSet(Automaton b) {
        Set<State> pre = new HashSet<State>();
        TreeSet<State> pending = new TreeSet<State>();
        pending.add(b.getInitialState());
        while (!pending.isEmpty()) {
            State p = pending.first();
            pending.remove(p);
            pre.add(p);
            for (Transition t : p.getTransitions()) {
                if (t.getMin() <= '\u0020') {
                    State q = t.getDest();
                    if (!pre.contains(q)) {
                        pending.add(q);
                    }
                }
            }
View Full Code Here

    static Set<State> findReachableStates(State s) {
        Set<State> reachable = new HashSet<State>();
        TreeSet<State> pending = new TreeSet<State>();
        pending.add(s);
        while (!pending.isEmpty()) {
            State p = pending.first();
            pending.remove(p);
            reachable.add(p);
            for (Transition t : p.getTransitions()) {
                State q = t.getDest();
                if (!reachable.contains(q)) {
                    pending.add(q);
                }
            }
        }
View Full Code Here

     * @return resulting automaton
     */
    @Override
    public Automaton op(Automaton a) {
        Automaton b = a.clone();
        State initial = new State();
        Set<StatePair> epsilons = new HashSet<StatePair>();
        for (State s : b.getStates()) {
            epsilons.add(new StatePair(initial, s));
        }
        b.setInitialState(initial);
View Full Code Here

        for (State s : b.getStates()) {
            Set<Transition> transitions = s.getTransitions();
            for (Transition t : new ArrayList<Transition>(transitions)) {
                char min = t.getMin();
                char max = t.getMax();
                State dest = t.getDest();
                if (min <= c && c <= max) {
                    transitions.remove(t);
                    transitions.add(new Transition(d, dest));
                    if (min < c) {
                        transitions.add(new Transition(min, (char) (c - 1), dest));
View Full Code Here

    public Automaton op(Automaton a) {
        Automaton a1 = a.clone();
        Map<State, State> map = new HashMap<State, State>();
        Set<State> a1s = a1.getStates();
        for (State s : a1s) {
            State p = new State();
            map.put(s, p);
            if (s.isAccept()) {
                p.setAccept(true);
                s.setAccept(false);
            }
        }
        for (State s : a1s) {
            State p = map.get(s);
            for (Transition t : s.getTransitions()) {
                p.addTransition(new Transition(t.getMin(), t.getMax(), map.get(t.getDest())));
            }
        }
        a1.setDeterministic(false);
        for (State s : a1s) {
            for (Transition t : map.get(s).getTransitions()) {
View Full Code Here

     * @return resulting automaton
     */
    @Override
    public Automaton op(Automaton a) {
        Automaton b = a.clone();
        State initial = new State();
        State accept = new State();
        accept.setAccept(true);
        Set<StatePair> epsilons = new HashSet<StatePair>();
        for (State s : b.getStates()) {
            epsilons.add(new StatePair(initial, s));
            epsilons.add(new StatePair(s, accept));
        }
View Full Code Here

    @Override
    public Automaton op(Automaton a) {
        Automaton b = new Automaton();
        Map<State, State> map = new HashMap<State, State>();
        for (State s : a.getStates()) {
            State ss = new State();
            map.put(s, ss);
        }
        State initial = new State();
        b.setInitialState(initial);
        map.get(a.getInitialState()).setAccept(true);
        Set<StatePair> epsilons = new HashSet<StatePair>();
        for (State s : a.getStates()) {
            State ss = map.get(s);
            if (s.isAccept()) {
                epsilons.add(new StatePair(initial, ss));
            }
            for (Transition t : s.getTransitions()) {
                State pp = map.get(t.getDest());
                pp.addTransition(new Transition(t.getMin(), t.getMax(), ss));
            }
        }
        b.setDeterministic(false);
        b.addEpsilons(epsilons);
        b.minimize();
View Full Code Here

    public Automaton op(Automaton a) {
        Automaton b = a.clone();
        for (State s : b.getStates()) {
            Set<Transition> transitions = s.getTransitions();
            for (Transition t : new ArrayList<Transition>(transitions)) {
                State dest = t.getDest();
                transitions.remove(t);
                transitions.add(new Transition(Character.MIN_VALUE, Character.MAX_VALUE, dest));
            }
        }
        b.setDeterministic(false);
View Full Code Here

TOP

Related Classes of dk.brics.automaton.State

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.