Esempio n. 1
0
        private QState AO_StateSearch_InState_InAction(QEvent e)
        {
            switch (e.sig)
            {
            case (int)HSMSignals.EXIT_SIG:
            case (int)HSMSignals.ENTRY_SIG:
            {
                return(handled);
            }

            case (int)Signals.NEW_WORD_SIG:
            {
                string tempWord = ((WordFeeder)e).Word;
                if (tempWord.Contains("return"))
                {
                    transition(AO_StateSearch_InState_ReturnFound);
                }
                else if (tempWord.Equals("case") && actionBlockScopeLevel == scopeLevel)
                {
                    transition(AO_StateSearch_InState_SigFound);
                }
                else if (tempWord.Equals("if"))
                {
                    newGuardedTransition = new GuardedTransition(newTransition.transitionName);
                    transition(AO_StateSearch_InState_IfBlock);
                }
            }
                return(handled);
            }
            return(AO_StateSearch_InState);
        }
Esempio n. 2
0
        private QState AO_StateSearch_InState_GuardedTransitionWaitingTarget(QEvent e)
        {
            switch (e.sig)
            {
            case (int)HSMSignals.EXIT_SIG:
            {
                ifTransition = null;
                return(handled);
            }

            case (int)HSMSignals.ENTRY_SIG:
            case (int)Signals.START_PARENTHESIS_SIG:
            case (int)Signals.END_PARENTHESIS_SIG:
            {
                return(handled);
            }

            case (int)Signals.NEW_WORD_SIG:
            {
                string tempWord    = ((WordFeeder)e).Word;
                bool   targetFound = false;

                tempWord = pruneAmpersand(tempWord);

                foreach (State s in currentAOParsing.states)
                {
                    if (s.stateName.Equals(tempWord))
                    {
                        ifTransition.targetState = s;
                        newGuardedTransition.transitions.Add(ifTransition);
                        targetFound = true;
                    }
                }

                if (!targetFound)
                {
                    State history = new State();
                    history.stateName = "Transition To History";
                    newGuardedTransition.transitions.Add(new Transition(tempWord, history));
                }

                ifBlockCondition = "";
                if (lastState == AO_StateSearch_InState)
                {
                    currentStateParsing.guardedTransitions.Add(newGuardedTransition);
                    newGuardedTransition = null;
                    newTransition        = null;
                }
                transition(lastState);
            }
                return(handled);
            }
            return(AO_StateSearch_InState_IfBlock);
        }
Esempio n. 3
0
        private QState AO_StateSearch_InState_IfBlock(QEvent e)
        {
            switch (e.sig)
            {
            case (int)HSMSignals.ENTRY_SIG:
            case (int)HSMSignals.EXIT_SIG:
            {
                return(handled);
            }

            case (int)Signals.START_PARENTHESIS_SIG:
            {
                lastState         = AO_StateSearch_InState_IfBlock;
                ifBlockCondition += "if (";
                transition(AO_StateSearch_InState_IfBlock_ConditionGather);
                return(handled);
            }

            case (int)Signals.END_LINE_SIG:
            case (int)Signals.NEW_WORD_SIG:
            {
                string tempWord = ((WordFeeder)e).Word;

                if (tempWord.Equals("else"))
                {
                    ifBlockCondition += "else ";
                    transition(AO_StateSearch_InState_IfBlock_Else);
                }
                else if (tempWord.Equals("break"))
                {
                    if (newGuardedTransition != null)
                    {
                        currentStateParsing.guardedTransitions.Add(newGuardedTransition);
                        newGuardedTransition = null;
                    }
                    newTransition = null;
                    transition(AO_StateSearch_InState);
                }
                return(handled);
            }
            }
            return(AO_StateSearch_InState);
        }
Esempio n. 4
0
        private QState AO_StateSearch_InState_IfBlock_WaitReturn(QEvent e)
        {
            switch (e.sig)
            {
            case (int)HSMSignals.ENTRY_SIG:
            case (int)HSMSignals.EXIT_SIG:
            case (int)Signals.START_PARENTHESIS_SIG:
            case (int)Signals.END_PARENTHESIS_SIG:
            {
                return(handled);
            }

            case (int)Signals.DECREMENT_SCOP_LEVEL_SIG:
            {
                this.scopeLevel--;
                if ((ifBlockScopeLevel - 1) == scopeLevel)
                {
                    ifBlockCondition     = "";
                    newGuardedTransition = null;
                    transition(AO_StateSearch_InState);
                }
                return(handled);
            }

            case (int)Signals.NEW_WORD_SIG:
            {
                string tempWord = ((WordFeeder)e).Word;
                if (tempWord.Contains("return") && ifBlockScopeLevel == scopeLevel)
                {
                    ifTransition = new Transition(ifBlockCondition, null);
                    transition(AO_StateSearchs_InState_GuardedTransitionReturnFound);
                }
                return(handled);
            }
            }
            return(AO_StateSearch_InState_IfBlock);
        }