static bool GroupIsValid(Racr.AstNode n) { return n.IsLValid() && n.GetBody().Children().All(x => ((Racr.AstNode)x).IsValid()); }
static bool FormIsValid(Racr.AstNode n) { return n.GetBody().Children(new Racr.Range(2)).All(x => ((Racr.AstNode)x).IsValid()); }
static Racr.AstNode GroupLLookup(Racr.AstNode n, string name) { return findL(name, n.GetBody(), n.GetBody().NumChildren()); }
static Racr.AstNode FormErrorQuestion(Racr.AstNode n) { return n.GetBody().Child(1); }
static public void UpdateQuestions(Racr.AstNode n) { switch (n.NodeType()) { case "Form": case "Group": foreach (var c in n.GetBody().Children()) UpdateQuestions(c as Racr.AstNode); break; case "ComputedQuestion": break; default: (n.Widget() as Widget).Set(n.Value()); break; } }
static string GroupSExpr(Racr.AstNode n) { return "(If " + n.GetExpression().SExpr() + " " + String.Join(" ", n.GetBody().Children().Select(x => ((Racr.AstNode)x).SExpr())) + ")"; }
static string FormSExpr(Racr.AstNode n) { return "(Form " + String.Join(" ", n.GetBody().Children().Skip(1).Select(x => ((Racr.AstNode)x).SExpr())) + ")"; }
static bool GroupRender(Racr.AstNode n) { foreach (var c in n.GetBody().Children()) { var child = c as Racr.AstNode; var w = child.Widget(); child.Render(); if (child.IsShown()) w.Show(); else child.Widget().Hide(); } return true; }