/// <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); }
public static EachOperator EachOperator(Token opToken) { EachOperator op = new EachOperator(null); op.OperatorToken = opToken; return(op); }
public static EachOperator EachOperator(Node function, Node expresson) { EachOperator op = EachOperator(function); op.RightArgument = expresson; return(op); }
public static EachOperator EachOperator(Node function, Node leftExpression, Node rightExpresson) { EachOperator op = EachOperator(function); op.RightArgument = rightExpresson; op.LeftArgument = leftExpression; return(op); }
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); }
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); }
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; }
public static EachOperator EachOperator(Token opToken) { EachOperator op = new EachOperator(null); op.OperatorToken = opToken; return op; }