void CreateArgListGui(List <PlaceHolder> l, CodeRender cr, string left, string right) { cr.Text(left, 0, bracketspacing); foreach (var arg in l) { cr.Push(arg); arg.RenderCode(cr, null, null); cr.Pop(arg); if (arg != l[l.Count - 1]) { cr.Text(",", 0, commaspacing); } } cr.Text(right, bracketspacing, 0); }
internal void RenderCodeChildren(CodeRender cr, string lb = "(", string rb = ")", int start = 0) { cr.Text(lb, 0, Program.bracketspacing); if (l != null) { for (var i = start; i < Arity(); i++) { At(i).RenderCode(cr, this); if (i != l.Count - 1) { cr.Text(",", 0, Program.commaspacing); } } } cr.Text(rb, Program.bracketspacing, 0); }
internal void RenderCode(CodeRender cr) { cr.StartTopLevel(); var i = 0; mf.ForAllFuncs(f => { cr.Push(null); cr.Push(f); f.RenderCode(cr, null, null); cr.Pop(f); CreateArgListGui(f.args, cr, "(", ")"); if (f.freevars.Count > 0) { cr.Scale(0.7, () => CreateArgListGui(f.freevars, cr, "[", "]")); } cr.Pop(null); cr.SaveFunctionLHS(); cr.Push(null); cr.Text("=", equalsspacing, equalsspacing); f.root.RenderCode(cr, null); cr.Pop(null); cr.Function(i++, f.Depth()); }); }
internal virtual void RenderCode(CodeRender cr, Node n, Node nparent) { cr.Text(name, Program.namespacing, Program.namespacing); }
internal override void RenderCode(CodeRender cr, Node n, Node nparent) { cr.WeightNext(700); cr.Text(name, Program.namespacing, Program.namespacing); }
internal override void RenderCode(CodeRender cr, Node n, Node nparent) { cr.Text("`" + (reff != null ? reff.name : name), Program.namespacing, Program.namespacing); }
internal override void RenderCode(CodeRender cr, Node n, Node nparent) { const double operatorscale = 1.3; string altop = null; switch (name) { case "!=": altop = "\u2260"; break; case "<=": altop = "\u2264"; break; case ">=": altop = "\u2265"; break; case "==": altop = "\u2A75"; break; case "*": altop = "\u2A2F"; break; case "/": altop = "\u00F7"; break; case "!": altop = "\u00AC"; break; case "|>": altop = "\u22B3"; break; } if (NeedsParens(nparent, n)) { cr.Text("(", 0, Program.bracketspacing); } if (name == "__apply") { n.At(0).RenderCode(cr, n); cr.Scale(operatorscale, () => cr.Text("!", 0, 0)); if (n.Arity() > 1) { n.RenderCodeChildren(cr, "(", ")", 1); } } else if (name == "|>") { n.At(1).RenderCode(cr, n); cr.AltNext(altop); cr.Scale(operatorscale, () => cr.Text("|>", Program.operatorspacing, Program.operatorspacing)); n.At(0).RenderCode(cr, n); } else if (name == "__list") { n.RenderCodeChildren(cr, "[", "]"); } else if (n.Arity() == 1) { cr.AltNext(altop); cr.Scale(operatorscale, () => cr.Text(name, Program.operatorspacing, Program.operatorspacing)); n.At(0).RenderCode(cr, n); } else if (n.Arity() == 2) { n.At(name == "=" ? 1 : 0).RenderCode(cr, n); cr.AltNext(altop); cr.Scale(operatorscale, () => cr.Text(name, Program.operatorspacing, Program.operatorspacing)); n.At(name == "=" ? 0 : 1).RenderCode(cr, n); } else { Debug.Assert(false); } if (NeedsParens(nparent, n)) { cr.Text(")", Program.bracketspacing, 0); } }
internal override void RenderCode(CodeRender cr, Node n, Node nparent) { cr.ColNext(Brushes.Green); cr.Text("\"" + name + "\"", Program.namespacing, Program.namespacing); }
internal override void RenderCode(CodeRender cr, Node n, Node nparent) { cr.ColNext(Brushes.Red); cr.Text(name, Program.namespacing, Program.namespacing); }