private static string ToDot(string parent, UserDefOperator node) { string name = String.Format("OperatorDef{0}", counter++); text.AppendFormat(" {0} "); if (node.Condition != null) { text.AppendFormat("[label=\"({1} {2} {3})\"]\n", name, node.Function.Name, node.Name, node.Condition.Name); } else { text.AppendFormat("[label=\"({1} {2})\"]\n", name, node.Function.Name, node.Name); } if (node.LeftArgument != null) { string leftArg = ToDot(name, node.LeftArgument); text.AppendFormat(" {0} -> {1};\n", name, leftArg); } string rightArg = ToDot(name, node.RightArgument); text.AppendFormat(" {0} -> {1};\n", name, rightArg); text.AppendFormat(" {0} -> {1};\n", name, ToDot(name, node.Codeblock)); return(name); }
/// <summary> /// Builds a <b>dyadic</b> user defined operator with a <b>dyadic</b> derived function. /// </summary> /// <remarks> /// Builds a representation of a <see cref="UserDefOperator"/> of the following structure: /// <example> /// a (f OP h) b: { ... } /// </example> /// </remarks> /// <param name="name">The name of the user defined operator.</param> /// <param name="function">The name of the function in the user defined operator.</param> /// <param name="condition">The name of the condition in the user defined operator.</param> /// <param name="leftArgument">The name of left argument of the user defined operator.</param> /// <param name="rightArgument">The name of the right argument of the user defined operator.</param> /// <param name="codeblock">The codeblock of the user defined operator.</param> /// <param name="codeText">The string representation of the user defined operator.</param> /// <returns>Returns a dyadic case of <see cref="UserDefOperator"/> AST node.</returns> public static UserDefOperator DyadicUserDefOperator( Identifier name, Identifier function, Identifier condition, Identifier leftArgument, Identifier rightArgument, Node codeblock, string codeText = "") { UserDefOperator result = DyadicUserDefOperator(name, function, condition, rightArgument, codeblock, codeText); result.LeftArgument = leftArgument; return(result); }
/// <summary> /// Builds a <b>dyadic</b> user defined operator with a <b>monadic</b> derived function. /// </summary> /// <remarks> /// Builds a representation of a <see cref="UserDefOperator"/> of the following structure: /// <example> /// (f OP h) b: { ... } /// </example> /// </remarks> /// <param name="name">The name of the user defined operator.</param> /// <param name="function">The name of the function in the user defined operator.</param> /// <param name="condition">The name of the condition in the user defined operator.</param> /// <param name="argument">The name of the monadic argument of the user defined operator.</param> /// <param name="codeblock">The codeblock of the user defined operator.</param> /// <param name="codeText">The string representation of the user defined operator.</param> /// <returns>Returns a dyadic case of <see cref="UserDefOperator"/> AST node.</returns> public static UserDefOperator DyadicUserDefOperator( Identifier name, Identifier function, Identifier condition, Identifier argument, Node codeblock, string codeText = "") { UserDefOperator result = MonadicUserDefOperator(name, function, argument, codeblock, codeText); result.Condition = condition; return(result); }
/// <summary> /// Builds a <b>monadic</b> user defined operator with a <b>monadic</b> derived function. /// </summary> /// <remarks> /// Builds a representation of a <see cref="UserDefOperator"/> of the following structure: /// <example> /// (f OP) b: { ... } /// </example> /// </remarks> /// <param name="name">The name of the user defined operator.</param> /// <param name="function">The name of the function in the user defined operator.</param> /// <param name="argument">The name of the monadic argument of the user defined operator.</param> /// <param name="codeblock">The codeblock of the user defined operator.</param> /// <param name="codeText">The string representation of the user defined operator.</param> /// <returns>Returns a monadic case of <see cref="UserDefOperator"/> AST node.</returns> public static UserDefOperator MonadicUserDefOperator( Identifier name, Identifier function, Identifier argument, Node codeblock, string codeText = "") { UserDefOperator result = new UserDefOperator(name, function, codeblock, codeText) { RightArgument = argument }; return(result); }
public override bool Equals(object obj) { if (obj is UserDefOperator) { UserDefOperator other = (UserDefOperator)obj; return((this.name == other.name) && (this.function == other.function) && (this.condition == other.condition) && (this.leftArgument == other.leftArgument) && (this.rightArgument == other.rightArgument) && (this.codeblock == other.codeblock)); } return(false); }
/// <summary> /// Builds a <b>monadic</b> user defined operator with a <b>monadic</b> derived function. /// </summary> /// <remarks> /// Builds a representation of a <see cref="UserDefOperator"/> of the following structure: /// <example> /// (f OP) b: { ... } /// </example> /// </remarks> /// <param name="name">The name of the user defined operator.</param> /// <param name="function">The name of the function in the user defined operator.</param> /// <param name="argument">The name of the monadic argument of the user defined operator.</param> /// <param name="codeblock">The codeblock of the user defined operator.</param> /// <param name="codeText">The string representation of the user defined operator.</param> /// <returns>Returns a monadic case of <see cref="UserDefOperator"/> AST node.</returns> public static UserDefOperator MonadicUserDefOperator( Identifier name, Identifier function, Identifier argument, Node codeblock, string codeText = "") { UserDefOperator result = new UserDefOperator(name, function, codeblock, codeText) { RightArgument = argument }; return result; }
private static string ToDot(string parent, UserDefOperator node) { string name = String.Format("OperatorDef{0}", counter++); text.AppendFormat(" {0} "); if (node.Condition != null) { text.AppendFormat("[label=\"({1} {2} {3})\"]\n", name, node.Function.Name, node.Name, node.Condition.Name); } else { text.AppendFormat("[label=\"({1} {2})\"]\n", name, node.Function.Name, node.Name); } if (node.LeftArgument != null) { string leftArg = ToDot(name, node.LeftArgument); text.AppendFormat(" {0} -> {1};\n", name, leftArg); } string rightArg = ToDot(name, node.RightArgument); text.AppendFormat(" {0} -> {1};\n", name, rightArg); text.AppendFormat(" {0} -> {1};\n", name, ToDot(name, node.Codeblock)); return name; }