//Used to format an AST node to incorporate its textual representation into an error message. //Parameter 'compact' is used to specify whether line brakes and parens should be added around output. private string FormatNode(ElaExpression exp, bool compact) { var str = exp.ToString(); str = str.Length > 100 ? str.Substring(0, 100) + " ..." : str; if (!compact && (str.IndexOf('\n') != -1 || str.Length > 40)) { str = "\r\n " + str + "\r\n"; } else if (!compact && str.Length > 0 && str[0] != '(' && str[0] != '"' && str[0] != '\'' && str[0] != '[') { str = "(" + str + ")"; } return(str); }
public static TreeNode Plain(this TreeNode par, ElaExpression exp) { return(Element(par, exp, "", exp.ToString(), "Function", "{0}{1}")); }