Ejemplo n.º 1
0
        void Parse(ParseController pc)
        {
            EnterHandle(pc.value, pc.controller);
            pc.ClearValues();

            while (pc.Next() != -1)
            {
                Transition transition = pc.transition;

                //removing key from value sequence
                if (transition.clearKeyBuffer)
                {
                    pc.ClearKey();
                }

                //if the value is meaningful
                if (transition.noZero && !pc.hasValue)
                {
                    continue;
                }

                if (transition.handler != null)
                {
                    var node = transition.handler(pc.value, pc.controller);
                    if (node != null)
                    {
                        pc.MoveTo(node);
                    }
                }
                if (transition.node != null)
                {
                    pc.MoveTo(transition.node);
                }
                if (transition.isExit)
                {
                    ExitHandle(pc.value, pc.controller);
                    return;
                }

                if (transition.clearOnBack)
                {
                    pc.ClearValues();
                }
            }

            if (!ignoreEnd)
            {
                throw new EndOfSequenceParseException();
            }
            ExitHandle(pc.value, pc.controller);
        }
Ejemplo n.º 2
0
        public object Parse(IEnumerable <Tsource> source, Tcontroller controller)
        {
            var pc = new ParseController(source, controller);

            pc.MoveTo(this);
            return(pc.controller.GetResult());
        }