Пример #1
0
 private void OnFunction(TokenLine.TokenEnum token)
 {
     if (token.PeekNext() == "(")
     {
         OperationsStack.Push(token.Current);
         OperationsStack.Push("(");
         token.MoveNext();
         if (token.PeekNext() != ")")
         {
             OperationsStack.Push(",");
         }
     }
     else
     {
         OperandsStack.Push(new MultiTreeNode <Value>(new Value(ValueType.Variable, token.Current)));
     }
 }
Пример #2
0
        private void ParseToken(TokenLine.TokenEnum token)
        {
            if (Library.IsFunction(token.Current))
            {
                OnFunction(token);
            }

            else if (token.Current == "[")
            {
                OnOpeningSquareBracket(token);
            }

            else if (RouteOperators.Contains(token.Current))
            {
                OperationsStack.Push(token.Current);
            }

            else if (token.Current == ")")
            {
                OnClosingBracket();
            }

            else if (token.Current == "]")
            {
                OnClosingSquareBracket();
            }

            else if (Library.IsOperator(token.Current))
            {
                while (OperationsStack.Count > 0 && Library.Operators[OperationsStack.Peek()] >= Library.Operators[token.Current])
                {
                    EvalOperator();
                }

                OperationsStack.Push(token.Current);
            }

            else
            {
                var value = Translator.ParseTypes(token.Current);
                OperandsStack.Push(value == null
                    ? new MultiTreeNode <Value>(new Value(ValueType.Variable, token.Current))
                    : new MultiTreeNode <Value>(new Value(ValueType.Value, value)));
            }
        }
Пример #3
0
 private void OnOpeningSquareBracket(TokenLine.TokenEnum token)
 {
     if (token.PeekPrev() == null || token.PeekPrev() == "(" || token.PeekPrev() == "[" ||
         Library.Operators.ContainsKey(token.PeekPrev()))
     {
         OperationsStack.Push("MkList");
         OperationsStack.Push("[");
         if (token.PeekNext() != "]")
         {
             OperationsStack.Push(",");
         }
     }
     else
     {
         OperationsStack.Push("ByIdx");
         OperationsStack.Push("[");
     }
 }