コード例 #1
0
            public System.Boolean GetStateEventAction(
                States CurState,
                System.Char CurChar,
                ref States NextState,
                ref NvtActions NextAction)
            {
                //prntSome.printSome("GetStateEventAction");
                uc_CharEventInfo Element;

                for (System.Int32 i = 0; i < uc_CharEvents.Elements.Length; i++)
                {
                    Element = uc_CharEvents.Elements[i];
                    if (CurChar >= Element.CharFrom &&
                        CurChar <= Element.CharTo &&
                        (CurState == Element.CurState || Element.CurState == States.Anywhere))
                    {
                        NextState  = Element.NextState;
                        NextAction = Element.NextAction;

                        return(true);
                    }
                }

                return(false);
            }
コード例 #2
0
 public uc_StateChangeInfo(
     States p1,
     Transitions p2,
     NvtActions p3)
 {
     //prntSome.printSome("uc_StateChangeInfo");
     this.State      = p1;
     this.Transition = p2;
     this.NextAction = p3;
 }
コード例 #3
0
 public NvtParserEventArgs(
     NvtActions p1,
     System.Char p2,
     System.String p3,
     uc_Params p4)
 {
     //prntSome.printSome("NvtParserEventArgs");
     Action      = p1;
     CurChar     = p2;
     CurSequence = p3;
     CurParams   = p4;
 }
コード例 #4
0
 public NvtParserEventArgs(
     NvtActions        p1,
     System.Char       p2,
     System.String     p3,
     uc_Params         p4)
 {
     //prntSome.printSome("NvtParserEventArgs");
     Action       = p1;
     CurChar      = p2;
     CurSequence  = p3;
     CurParams    = p4;
 }
コード例 #5
0
        public void ParseString(System.String InString)
        {
            //prntSome.printSome("ParseString");
            States     NextState        = States.None;
            NvtActions NextAction       = NvtActions.None;
            NvtActions StateExitAction  = NvtActions.None;
            NvtActions StateEntryAction = NvtActions.None;

            foreach (System.Char C in InString)
            {
                this.CurChar = C;

                // Get the next state and associated action based
                // on the current state and char event
                CharEvents.GetStateEventAction(State, CurChar, ref NextState, ref NextAction);

                // execute any actions arising from leaving the current state
                if (NextState != States.None && NextState != this.State)
                {
                    // check for state exit actions
                    StateChangeEvents.GetStateChangeAction(this.State, Transitions.Exit, ref StateExitAction);

                    // Process the exit action
                    if (StateExitAction != NvtActions.None)
                    {
                        DoAction(StateExitAction);
                    }
                }

                // process the action specified
                if (NextAction != NvtActions.None)
                {
                    DoAction(NextAction);
                }

                // set the new parser state and execute any actions arising entering the new state
                if (NextState != States.None && NextState != this.State)
                {
                    // change the parsers state attribute
                    this.State = NextState;

                    // check for state entry actions
                    StateChangeEvents.GetStateChangeAction(this.State, Transitions.Entry, ref StateExitAction);

                    // Process the entry action
                    if (StateEntryAction != NvtActions.None)
                    {
                        DoAction(StateEntryAction);
                    }
                }
            }
        }
コード例 #6
0
            public States      NextState;    // the next state we are going to

            public uc_CharEventInfo(
                States p1,
                System.Char p2,
                System.Char p3,
                NvtActions p4,
                States p5)
            {
                //prntSome.printSome("uc_CharEventInfo");
                this.CurState   = p1;
                this.CharFrom   = p2;
                this.CharTo     = p3;
                this.NextAction = p4;
                this.NextState  = p5;
            }
コード例 #7
0
            public System.Boolean GetStateChangeAction(
                States State,
                Transitions Transition,
                ref NvtActions NextAction)
            {
                //prntSome.printSome("GetStateChangeAction");
                uc_StateChangeInfo Element;

                for (System.Int32 i = 0; i < Elements.Length; i++)
                {
                    Element = Elements[i];

                    if (State == Element.State &&
                        Transition == Element.Transition)
                    {
                        NextAction = Element.NextAction;
                        return(true);
                    }
                }

                return(false);
            }
コード例 #8
0
        private void DoAction(NvtActions NextAction)
        {
            //prntSome.printSome("DoAction");
            // Manage the contents of the Sequence and Param Variables
            switch (NextAction)
            {
            case NvtActions.Dispatch:
            case NvtActions.Collect:
                this.CurSequence += CurChar.ToString();
                break;

            case NvtActions.NewCollect:
                this.CurSequence = CurChar.ToString();
                this.CurParams.Clear();
                break;

            case NvtActions.Param:
                this.CurParams.Add(CurChar);
                break;

            default:
                break;
            }

            // send the external event requests
            switch (NextAction)
            {
            case NvtActions.Dispatch:
                //System.Console.Write
                //rdbsb.Append(System.String.Format("Seq:{0},Char:{1},NxtAct:{4}\n",
                //   this.CurSequence, (int) this.CurChar, this.CurParams.Count (),
                //   this.State, NextAction));

                NvtParserEvent(this, new NvtParserEventArgs(NextAction, CurChar, CurSequence, CurParams));
                break;

            case NvtActions.Execute:
            case NvtActions.SendUp:
                NvtParserEvent(this, new NvtParserEventArgs(NextAction, CurChar, CurSequence, CurParams));

                //rdbsb.Append(System.String.Format("Seq:{0},Char:{1},NxtAct:{4}\n",
                //    this.CurSequence, (int) this.CurChar, this.CurParams.Count (),
                //    this.State, NextAction));
                break;

            default:
                break;
            }


            switch (NextAction)
            {
            case NvtActions.Dispatch:
                this.CurSequence = "";
                this.CurParams.Clear();
                break;

            default:
                break;
            }
        }
コード例 #9
0
                public System.Boolean GetStateChangeAction(
                    States      State,
                    Transitions Transition,
                    ref NvtActions  NextAction)
                {
                    uc_StateChangeInfo Element;

                    for (System.Int32 i = 0; i < Elements.Length; i++)
                    {
                        Element = Elements[i];

                        if (State      == Element.State &&
                            Transition == Element.Transition)
                        {
                            NextAction = Element.NextAction;
                            return true;
                        }
                    }

                    return false;
                }
コード例 #10
0
                public System.Boolean GetStateEventAction(
                    States         CurState,
                    System.Char    CurChar,
                    ref States     NextState,
                    ref NvtActions NextAction)
                {
                    uc_CharEventInfo Element;

                    for (System.Int32 i = 0; i < uc_CharEvents.Elements.Length; i++)
                    {
                        Element = uc_CharEvents.Elements[i];

                        if (CurChar  >= Element.CharFrom &&
                            CurChar  <= Element.CharTo   &&
                            (CurState == Element.CurState || Element.CurState == States.Anywhere))
                        {
                            NextState  = Element.NextState;
                            NextAction = Element.NextAction;
                            return true;
                        }
                    }

                    return false;
                }
コード例 #11
0
                public Transitions Transition; // the next state we are going to

                #endregion Fields

                #region Constructors

                public uc_StateChangeInfo(
                    States      p1,
                    Transitions p2,
                    NvtActions  p3)
                {
                    this.State      = p1;
                    this.Transition = p2;
                    this.NextAction = p3;
                }
コード例 #12
0
                public States NextState; // the next state we are going to

                #endregion Fields

                #region Constructors

                public uc_CharEventInfo(
                    States  p1,
                    System.Char   p2,
                    System.Char   p3,
                    NvtActions    p4,
                    States  p5)
                {
                    this.CurState   = p1;
                    this.CharFrom   = p2;
                    this.CharTo     = p3;
                    this.NextAction = p4;
                    this.NextState  = p5;
                }
コード例 #13
0
            private void DoAction(NvtActions NextAction)
            {
                // Manage the contents of the Sequence and Param Variables
                switch (NextAction)
                {
                    case NvtActions.Dispatch:
                    case NvtActions.Collect:
                        this.CurSequence += CurChar.ToString ();
                        break;

                    case NvtActions.NewCollect:
                        this.CurSequence = CurChar.ToString ();
                        this.CurParams.Clear ();
                        break;

                    case NvtActions.Param:
                        this.CurParams.Add (CurChar);
                        break;

                    default:
                        break;
                }

                // send the external event requests
                switch (NextAction)
                {
                    case NvtActions.Dispatch:

                        //                    System.Console.Write ("Sequence = {0}, Char = {1}, PrmCount = {2}, State = {3}, NextAction = {4}\n",
                        //                        this.CurSequence, (int) this.CurChar, this.CurParams.Count (),
                        //                        this.State, NextAction);

                        NvtParserEvent (this, new NvtParserEventArgs (NextAction, CurChar, CurSequence, CurParams));
                        break;

                    case NvtActions.Execute:
                    case NvtActions.SendUp:
                        NvtParserEvent (this, new NvtParserEventArgs (NextAction, CurChar, CurSequence, CurParams));

                        //                    System.Console.Write ("Sequence = {0}, Char = {1}, PrmCount = {2}, State = {3}, NextAction = {4}\n",
                        //                        this.CurSequence, (int) this.CurChar, this.CurParams.Count (),
                        //                        this.State, NextAction);
                        break;
                    default:
                        break;
                }

                switch (NextAction)
                {
                    case NvtActions.Dispatch:
                        this.CurSequence = "";
                        this.CurParams.Clear ();
                        break;

                    default:
                        break;
                }
            }
コード例 #14
0
 public uc_StateChangeInfo(
     States      p1,
     Transitions p2,
     NvtActions  p3)
 {
     //prntSome.printSome("uc_StateChangeInfo");
     this.State      = p1;
     this.Transition = p2;
     this.NextAction = p3;
 }