Inheritance: LispEngine.Datums.DatumHelpers
示例#1
0
 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;
     }
 }
示例#2
0
        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());
        }