public static IEnumerable<Datum> ReadDatums(Assembly assembly, string resourceFile) { var stream = assembly.GetManifestResourceStream(resourceFile); if (stream == null) throw new Exception(string.Format("Unable to find '{0}' embedded resource", resourceFile)); var s = new Scanner(new StreamReader(stream)) { Filename = resourceFile }; var p = new Parser(s); Datum d; while ((d = p.parse()) != null) { yield return d; } }
private static void test(string sexp, params Datum[] expected) { Console.WriteLine("sexp: {0}", sexp); var s = Scanner.Create(sexp); var p = new Parser(s); var actual = new List<Datum>(); Datum parsed; while( (parsed = p.parse()) != null) actual.Add(parsed); Assert.AreEqual(expected, actual.ToArray()); }