コード例 #1
0
ファイル: scanner.cs プロジェクト: rbirkby/gedcomreader
        /// <summary>
        /// Test Main() for when we compile this as a standalone console app during
        /// development
        /// </summary>
        public static void Main()
        {
            TextWriter outputStream = Console.Out; //new StreamWriter(@"c:\output.txt");

            Stream inputStream = new MemoryStream(Encoding.ASCII.GetBytes(_testGedcomTransmission));
            var scanner = new Scanner(inputStream, false);

            ReadAll(scanner, outputStream);

            inputStream.Close();

            inputStream = new FileStream(@"D:\Software Library\Old Pendleton\2003-05-01.ged", FileMode.Open, FileAccess.Read);
            scanner = new Scanner(inputStream, false);
            DateTime timer = DateTime.Now;

            ReadAll(scanner, outputStream);

            Console.WriteLine("Full token scan took {0} seconds", DateTime.Now - timer);
            inputStream.Close();

            Console.WriteLine("Press any key to continue...");

            Console.ReadLine();
        }
コード例 #2
0
ファイル: scanner.cs プロジェクト: rbirkby/gedcomreader
        /// <summary>
        /// Test method used during development
        /// </summary>
        /// <param name="scanner"></param>
        /// <param name="output"></param>
        private static void ReadAll(Scanner scanner, TextWriter output)
        {
            int token = None;

            while (token != Eof)
            {
                scanner.NextToken();
                token = scanner.CurrentToken;

            #if DEBUG
                switch(token) {
                    case Eol:
                        output.WriteLine("[EOL]");
                        break;
                    case Level:
                        output.WriteLine("[LEVEL] {" + new string(scanner.Lexeme) + "}");
                        break;
                    case Tag:
                        output.WriteLine("[TAG] {" + new string(scanner.Lexeme) + "}");
                        break;
                    case Xref:
                        output.WriteLine("[XREF] {" + new string(scanner.Lexeme) + "}");
                        break;
                    case Eof:
                        output.WriteLine("[EOF]" );
                        break;
                    case Text:
                        output.WriteLine("[TEXT] {" + new string(scanner.Lexeme) + "}");
                        break;
                    default:
                        output.WriteLine("[UNKNOWN] {" + new string(scanner.Lexeme) + "}");
                        break;
                }
            #endif
            }
        }
コード例 #3
0
ファイル: GedcomReader.cs プロジェクト: rbirkby/gedcomreader
 /// <summary>
 /// Creates a new GEDCOM Reader to read from a stream
 /// </summary>
 /// <param name="stream"></param>
 public GedcomReader(Stream stream)
 {
     _scanner = new Scanner(stream, false);
 }