예제 #1
0
        public static Grefs Parse(TextReader reader, int?pid = null, GrefParseOptions options = 0)
        {
            var r = new Grefs()
            {
                ParseOptions = options,
            };
            var h = r.CreateHandlers(pid);

            int    lineNumber = 0;
            string line;

            while ((line = reader.ReadLine()) != null)
            {
                lineNumber++;
                foreach (var e in h)
                {
                    var m = e.Key.Match(line);
                    if (m.Success)
                    {
                        e.Value(m, lineNumber);
                        break;
                    }
                }
            }

            return(r);
        }
예제 #2
0
        void LogWarning(GrefParseOptions type, string message)
        {
            Console.WriteLine("Warning: {0}", message);

            GrefParseOptions shouldThrow = type | GrefParseOptions.ThrowExceptionOnMismatch;

            if ((ParseOptions & shouldThrow) == shouldThrow)
            {
                throw new InvalidOperationException(message);
            }
        }
예제 #3
0
 public static Grefs Parse(string filename, int?pid = null, GrefParseOptions options = 0)
 {
     using (var source = new StreamReader(filename))
         return(Parse(source, pid, options));
 }