Ejemplo n.º 1
0
        public List <Transition <string> > Or(string beginState, string endState)
        {
            List <Transition <string> > transitions = new List <Transition <string> >();
            Transition <string>         leftTo      = new Transition <string>(beginState, '$', getStateNumber());
            Transition <string>         leftFrom    = new Transition <string>(getStateNumber(), '$', endState);
            Transition <string>         rightTo     = new Transition <string>(beginState, '$', getStateNumber());
            Transition <string>         rightFrom   = new Transition <string>(getStateNumber(), '$', endState);

            if (this.left != null)
            {
                var left = new ThompsonBox(this.left, leftTo.toState, leftFrom.fromState);
                transitions = transitions.Concat(left.GetTransitions()).ToList();
            }

            if (this.right != null)
            {
                var right = new ThompsonBox(this.right, rightTo.toState, rightFrom.fromState);
                transitions = transitions.Concat(right.GetTransitions()).ToList();
            }

            transitions.Add(leftTo);
            transitions.Add(leftFrom);
            transitions.Add(rightTo);
            transitions.Add(rightFrom);

            return(transitions);
        }
Ejemplo n.º 2
0
        public List <Transition <string> > Star(string beginState, string endState)
        {
            List <Transition <string> > transitions = new List <Transition <string> >();
            Transition <string>         beginBox    = new Transition <string>(beginState, '$', getStateNumber());
            Transition <string>         beginEnd    = new Transition <string>(beginState, '$', endState);
            Transition <string>         boxBack     = new Transition <string>(getStateNumber(), '$', beginBox.toState);
            Transition <string>         boxEnd      = new Transition <string>(boxBack.fromState, '$', endState);

            if (this.left != null)
            {
                var left = new ThompsonBox(this.left, beginBox.toState, boxBack.fromState);
                transitions = transitions.Concat(left.GetTransitions()).ToList();
            }

            if (this.right != null)
            {
                var right = new ThompsonBox(this.right, beginBox.toState, boxBack.fromState);
                transitions = transitions.Concat(right.GetTransitions()).ToList();
            }

            transitions.Add(beginBox);
            transitions.Add(beginEnd);
            transitions.Add(boxBack);
            transitions.Add(boxEnd);

            return(transitions);
        }
Ejemplo n.º 3
0
        public List <Transition <string> > Plus(string beginState, string endState)
        {
            List <Transition <string> > transitions  = new List <Transition <string> >();
            Transition <string>         plusBeginBox = new Transition <string>(beginState, '$', getStateNumber());
            Transition <string>         plusBoxEnd   = new Transition <string>(getStateNumber(), '$', endState);
            Transition <string>         plusBeginEnd = new Transition <string>(beginState, '$', endState);

            if (this.left != null)
            {
                var left = new ThompsonBox(this.left, plusBeginBox.toState, plusBoxEnd.fromState);
                transitions = transitions.Concat(left.GetTransitions()).ToList();
            }

            transitions.Add(plusBeginBox);
            transitions.Add(plusBeginEnd);
            transitions.Add(plusBoxEnd);

            return(transitions);
        }
Ejemplo n.º 4
0
        public List <Transition <string> > Dot(string beginState, string endState)
        {
            List <Transition <string> > transitions = new List <Transition <string> >();
            Transition <string>         link        = new Transition <string>(getStateNumber(), '$', getStateNumber());

            if (this.left != null)
            {
                var left = new ThompsonBox(this.left, beginState, link.fromState);
                transitions = transitions.Concat(left.GetTransitions()).ToList();
            }

            if (this.right != null)
            {
                var right = new ThompsonBox(this.right, link.toState, endState);
                transitions = transitions.Concat(right.GetTransitions()).ToList();
            }

            transitions.Add(link);

            return(transitions);
        }