Example #1
0
        /// <summary>
        /// Updates the properties of the <see cref="Operator"/> based on the <paramref name="expressionList"/> parameter.
        /// </summary>
        /// <param name="op">The <see cref="Operator"/> to update.</param>
        /// <param name="expressionList">The list of arguments wrapped in an <see cref="ExpressionList"/>.</param>
        /// <exception cref="ParseException"></exception>
        /// <returns>Returns the updated <see cref="Operator"/>.</returns>
        public static Node BuiltinOpInvoke(Operator op, ExpressionList expressionList)
        {
            switch (expressionList.Length)
            {
            case 1:
                op.RightArgument = expressionList[0];
                break;

            case 2:
                op.RightArgument = expressionList[1];
                op.LeftArgument  = expressionList[0];
                break;

            default:
                if (!(op is EachOperator))
                {
                    throw new ParseException("Valence", false);
                }

                EachOperator eachOp = (EachOperator)op;
                eachOp.IsGeneralApply = true;
                eachOp.RightArgument  = expressionList;
                break;
            }

            return(op);
        }
Example #2
0
        public static EachOperator EachOperator(Token opToken)
        {
            EachOperator op = new EachOperator(null);

            op.OperatorToken = opToken;
            return(op);
        }
Example #3
0
        public static EachOperator EachOperator(Node function, Node expresson)
        {
            EachOperator op = EachOperator(function);

            op.RightArgument = expresson;
            return(op);
        }
Example #4
0
        public static EachOperator EachOperator(Node function, Node leftExpression, Node rightExpresson)
        {
            EachOperator op = EachOperator(function);

            op.RightArgument = rightExpresson;
            op.LeftArgument  = leftExpression;
            return(op);
        }
Example #5
0
        public override bool Equals(object obj)
        {
            if (obj is EachOperator)
            {
                EachOperator other  = (EachOperator)obj;
                bool         result = (this.function == other.function) && (this.rightarg == other.rightarg);
                if (isDyadic)
                {
                    result = result && (this.leftarg == other.leftarg);
                }
                return(result);
            }

            return(false);
        }
Example #6
0
        private static string ToDot(string parent, EachOperator node)
        {
            string name    = String.Format("EachOP{0}", counter++);
            string funcDot = ToDot(name, node.Function);

            text.AppendFormat(" {0} -> {1};\n", name, funcDot);

            if (node.isDyadic)
            {
                string leftArg = ToDot(name, node.LeftArgument);
                text.AppendFormat("  {0} -> {1};\n", name, leftArg);
            }

            if (node.RightArgument != null)
            {
                string rightArg = ToDot(name, node.RightArgument);
                text.AppendFormat(" {0} -> {1};\n", name, rightArg);
                text.AppendFormat(" {0} [label=\"{1} Each\"]", name, node.Function);
            }

            return(name);
        }
Example #7
0
        private static string ToDot(string parent, EachOperator node)
        {
            string name = String.Format("EachOP{0}", counter++);
            string funcDot = ToDot(name, node.Function);
            text.AppendFormat(" {0} -> {1};\n", name, funcDot);

            if (node.isDyadic)
            {
                string leftArg = ToDot(name, node.LeftArgument);
                text.AppendFormat("  {0} -> {1};\n", name, leftArg);
            }

            if (node.RightArgument != null)
            {
                string rightArg = ToDot(name, node.RightArgument);
                text.AppendFormat(" {0} -> {1};\n", name, rightArg);
                text.AppendFormat(" {0} [label=\"{1} Each\"]", name, node.Function);
            }

            return name;
        }
Example #8
0
 public static EachOperator EachOperator(Token opToken)
 {
     EachOperator op = new EachOperator(null);
     op.OperatorToken = opToken;
     return op;
 }