public static LNode @case(LNode node, IMacroContext context) { LNode expr, braces = null; if (node.ArgCount == 2 && (braces = node.Args.Last).Calls(S.Braces) || node.ArgCount == 1 && (node[0].Calls(S.Colon, 2) || node[0].Calls("'or", 2))) { expr = node[0]; var results = LNode.List(); while (expr.Calls("'or", 2)) { results.Add(LNode.Call(S.Case, LNode.List(expr[0]), expr[0])); expr = expr[1]; } if (braces != null) { results.Add(LNode.Call(S.Case, LNode.List(expr), expr)); return(F.Call(S.Splice, results.Add(braces))); } else if (expr.Calls(S.Colon, 2)) { results.Add(LNode.Call(S.Case, LNode.List(expr[0]), expr[0])); return(F.Call(S.Splice, results.Add(expr[1]))); } else { return(Les2.Reject(context, node, "Unrecognized syntax in case statement")); } } return(null); }
public static LNode Prop(LNode node, IMacroContext context) { LNode visibility = node.Target; if (visibility.Name != sy__numprop) { node = node.PlusAttr(visibility); } { LNode getExpr, init = null, name, tmp_12 = null, tmp_13 = null, tmp_14, tmp_15, type; LNodeList content; if (node.Args.Count == 2 && (tmp_12 = node.Args[0]) != null && tmp_12.Calls(CodeSymbols.Colon, 2) && (name = tmp_12.Args[0]) != null && (type = tmp_12.Args[1]) != null && node.Args[1].Calls(CodeSymbols.Braces) && (content = node.Args[1].Args).IsEmpty | true || node.Args.Count == 3 && (tmp_13 = node.Args[0]) != null && tmp_13.Calls(CodeSymbols.Colon, 2) && (name = tmp_13.Args[0]) != null && (type = tmp_13.Args[1]) != null && node.Args[1].Calls(CodeSymbols.Braces) && (content = node.Args[1].Args).IsEmpty | true && node.Args[2].Calls((Symbol)"#initially", 1) && (init = node.Args[2].Args[0]) != null) { LNode args = GetArgList(ref name); var newBody = LNode.List(); foreach (var part_ in content) { LNode part = part_; { LNode body, value; if (part.Calls((Symbol)"#get", 0)) { part = LNode.Id(S.get, part); } else if (part.Calls((Symbol)"#get", 1) && (body = part.Args[0]) != null) { part = part.WithName(S.get); if (body.Calls(S.Braces)) { part = part.SetBaseStyle(NodeStyle.Special); } else { part = part.With(S.Lambda, part.Target, body); } } else if (part.Calls((Symbol)"#set", 0)) { part = LNode.Id(S.set, part); } else if (part.Calls((Symbol)"#set", 1) && (body = part.Args[0]) != null) { part = part.WithName(S.set); if (body.Calls(S.Braces)) { part = part.SetBaseStyle(NodeStyle.Special); } else { part = part.With(S.Lambda, part.Target, body); } } else if (part.Calls((Symbol)"#init", 1) && (value = part.Args[0]) != null) { init = value; part = null; } } if (part != null) { newBody.Add(part); } } if (init != null) { if (newBody.IsEmpty) { newBody.Add(F.Id(S.get)); } return(node.With(S.Property, type, name, args, F.Braces(newBody), init)); } else { return(node.With(S.Property, type, name, args, F.Braces(newBody))); } } else if (node.Args.Count == 1 && (tmp_14 = node.Args[0]) != null && tmp_14.Calls(CodeSymbols.Colon, 2) && (name = tmp_14.Args[0]) != null && (tmp_15 = tmp_14.Args[1]) != null && tmp_15.Calls(CodeSymbols.Lambda, 2) && (type = tmp_15.Args[0]) != null && (getExpr = tmp_15.Args[1]) != null) { var args = GetArgList(ref name); return(node.With(S.Property, type, name, args, getExpr)); } } return(Les2.Reject(context, node, "Unrecognized property syntax")); LNode GetArgList(ref LNode name_apos) { if (name_apos.Calls(S.IndexBracks)) { var args = name_apos.Args.RemoveAt(0); name_apos = name_apos[0].PlusAttrs(name_apos.Attrs); return(F.Call(S.AltList, args)); } else { return(LNode.Missing); } } }