Exemplo n.º 1
0
 private void State_11()
 {
     // 11 //
     if (isCurrentLexemID())
     {
         CurrentState = 12;
         lexemsIterator++;
         State_12();
     }
     else if (CurrentLexemValue() == "input" || CurrentLexemValue() == "output")
     {
         CurrentState = 14;
         lexemsIterator++;
         State_14();
     }
     else if (CurrentLexemValue() == "if")
     {
         CurrentState = 51;
         lexemsIterator++;
         Out.Log(Out.State.LogInfo, "Call half-automat LOGICAL EXPRESSION");
         ActionStack.Push(State_17);
         HalfAutomatLogicalExpression();
     }
     else if (CurrentLexemValue() == "for")
     {
         CurrentState = 23;
         lexemsIterator++;
         State_23();
     }
     else
     {
         throw new LexemException(CurrentLineNumber(), "Invalid operator");
     }
 }
Exemplo n.º 2
0
 private void State_34()
 {
     if (ActionStack.Last() != ActionStack.WrongLexem)
     {
         Action returnState = ActionStack.Pop();
         returnState();
     }
 }
Exemplo n.º 3
0
        public static Action Pop()
        {
            Action returnValue = ActionStack.Last();

            if (returnValue != ActionStack.WrongLexem)
            {
                _stack.RemoveAt(_stack.Count - 1);
            }
            return(returnValue);
        }
Exemplo n.º 4
0
 private void State_29()
 {
     if (CurrentLexemValue() == "next")
     {
         Action returnState = ActionStack.Pop();
         lexemsIterator++;
         returnState();
     }
     else
     {
         throw new LexemException(CurrentLineNumber(), "Missed next");
     }
 }
Exemplo n.º 5
0
 private void State_27()
 {
     if (CurrentLexemValue() == "\n")
     {
         ActionStack.Push(State_28);
         lexemsIterator++;
         HalfAutomatOperatorsBlock();
     }
     else
     {
         throw new LexemException(CurrentLineNumber(), "Missed ENTER");
     }
 }
Exemplo n.º 6
0
 private void State_26()
 {
     if (CurrentLexemValue() == "step")
     {
         ActionStack.Push(State_27);
         lexemsIterator++;
         HalfAutomatExpression();
     }
     else
     {
         throw new LexemException(CurrentLineNumber(), "Missed step");
     }
 }
Exemplo n.º 7
0
 private void State_53()
 {
     if (CurrentLexemValue() == "or" || CurrentLexemValue() == "and")
     {
         CurrentState = 51;
         lexemsIterator++;
         State_51();
     }
     else
     {
         Action returnState = ActionStack.Pop();
         returnState();
     }
 }
Exemplo n.º 8
0
 private void State_33()
 {
     if (CurrentLexemValue() == "}")
     {
         Action returnState = ActionStack.Pop();
         lexemsIterator++;
         returnState();
     }
     else
     {
         ActionStack.Push(State_32);
         HalfAutomatOperator();
     }
 }
Exemplo n.º 9
0
 private void State_31()
 {
     if (CurrentLexemValue() == "{")
     {
         CurrentState = 32;
         lexemsIterator++;
         State_32();
     }
     else
     {
         ActionStack.Push(State_34);
         HalfAutomatOperator();
     }
 }
Exemplo n.º 10
0
 private void State_8()
 {
     if (CurrentLexemValue() == "@end")
     {
         Out.Log(Out.State.LogInfo, "Syntax Analyzer finish success");
         return;
     }
     else
     {
         CurrentState = 11;
         ActionStack.Push(State_7);
         Out.Log(Out.State.LogInfo, "Call half-automat OPERATOR");
         HalfAutomatOperator();
     }
 }
Exemplo n.º 11
0
        private void State_54()
        {
            HashSet <string> operators = new HashSet <string>()
            {
                ">", ">=", "<", "<=", "equ", "!="
            };

            if (operators.Contains(CurrentLexemValue()))
            {
                ActionStack.Push(State_53);
                lexemsIterator++;
                HalfAutomatExpression();
            }
            else
            {
                throw new LexemException(CurrentLineNumber(), "Unknow operator " + CurrentLexemValue());
            }
        }
Exemplo n.º 12
0
        private void State_42()
        {
            HashSet <string> operators = new HashSet <string>()
            {
                "+", "-", "*", "/", "^"
            };

            if (operators.Contains(CurrentLexemValue()))
            {
                CurrentState = 41;
                lexemsIterator++;
                State_41();
            }
            else
            {
                Action returnState = ActionStack.Pop();
                returnState();
            }
        }
Exemplo n.º 13
0
 private void State_41()
 {
     if (isCurrentLexemID() || isCurrentLexemCONST())
     {
         CurrentState = 42;
         lexemsIterator++;
         State_42();
     }
     else if (CurrentLexemValue() == "(")
     {
         ActionStack.Push(State_43);
         lexemsIterator++;
         HalfAutomatExpression();
     }
     else
     {
         throw new LexemException(CurrentLineNumber(), "Missed ( or ID or CONST");
     }
 }
Exemplo n.º 14
0
 private void State_16()
 {
     if (CurrentLexemValue() == ",")
     {
         CurrentState = 15;
         lexemsIterator++;
         State_15();
     }
     else if (CurrentLexemValue() == ")")
     {
         Action returnState = ActionStack.Pop();
         lexemsIterator++;
         returnState();
     }
     else
     {
         throw new LexemException(CurrentLineNumber(), "Missed ) or ,");
     }
 }
Exemplo n.º 15
0
 private void State_51()
 {
     if (CurrentLexemValue() == "!")
     {
         CurrentState = 51;
         lexemsIterator++;
         State_51();
     }
     else if (CurrentLexemValue() == "[")
     {
         ActionStack.Push(State_52);
         lexemsIterator++;
         HalfAutomatLogicalExpression();
     }
     else
     {
         ActionStack.Push(State_54);
         HalfAutomatExpression();
     }
 }