public dynamic Eval(string s, Rule r) { var nodes = r.Parse(s); var root = JavaScriptTransformer.Transform(nodes[0]); return(Eval(root)); }
public static void Test(string s, Rule r) { try { Print(string.Format("Using rule {0} to parse string {1}", r.Name, s)); var nodes = r.Parse(s); if (nodes == null || nodes.Count != 1) { Print("Parsing failed!", ConsoleColor.Red); } else if (nodes[0].Text != s) { Print("Parsing partially succeeded", ConsoleColor.Yellow); } else { Print("Parsing suceeded", ConsoleColor.Green); } if (nodes != null && nodes.Count > 0) { Console.WriteLine(nodes[0].Text + "\n"); } else { Console.WriteLine(); } } catch (Exception e) { Print("Parsing failed with exception:", ConsoleColor.Red); Print(e.Message + "\n" + e.StackTrace + "\n", ConsoleColor.Gray); } }
public static void Test(string s, Rule r) { try { Console.WriteLine("Using rule {0} to parse string {1}", r.Name, s); var nodes = r.Parse(s); if (nodes == null || nodes.Count != 1) { Console.WriteLine("Parsing failed!"); } else if (nodes[0].Text != s) { Console.WriteLine("Parsing partially succeeded"); } else { Console.WriteLine("Parsing suceeded"); } Console.WriteLine(nodes[0].Text); } catch (Exception e) { Console.WriteLine("Parsing failed with exception" + e.Message); } }
public static void Test(string input, Rule r) { var nodes = r.Parse(input); if (nodes == null) throw new Exception("Parser failed"); foreach (var n in nodes) { if (n.Label == "Object") { var d = JsonObject.Eval(n); var s = d.ToString(); Console.WriteLine(s); } else { Console.WriteLine(n.ToXml.ToString()); } } }
public static void Test(string s, Rule r) { try { Console.WriteLine("Using rule {0} to parse string {1}", r.Name, s); var nodes = r.Parse(s); if (nodes == null || nodes.Count != 1) Console.WriteLine("Parsing failed!"); else if (nodes[0].Text != s) Console.WriteLine("Parsing partially succeeded"); else Console.WriteLine("Parsing suceeded"); Console.WriteLine(nodes[0].Text); } catch (Exception e) { Console.WriteLine("Parsing failed with exception" + e.Message); } }
public static void Test(string input, Rule r) { var nodes = r.Parse(input); if (nodes == null) { throw new Exception("Parser failed"); } foreach (var n in nodes) { if (n.Label == "Object") { var d = JsonObject.Eval(n); var s = d.ToString(); Console.WriteLine(s); } else { Console.WriteLine(n.ToXml.ToString()); } } }
public dynamic Eval(string s, Rule r) { var nodes = r.Parse(s); var root = JavaScriptTransformer.Transform(nodes[0]); return Eval(root); }