Пример #1
0
        public CSharpFile(CSharpProject project, string fileName)
        {
            this.Project     = project;
            this.FileName    = fileName;
            this.Content     = new StringTextSource(File.ReadAllText(FileName));
            this.LinesOfCode = 1 + this.Content.Text.Count(c => c == '\n');

            CSharpParser p = project.CreateParser();

            this.CompilationUnit = p.Parse(Content.CreateReader(), fileName);
            if (p.HasErrors)
            {
                Console.WriteLine("Error parsing " + fileName + ":");
                foreach (var error in p.ErrorPrinter.Errors)
                {
                    Console.WriteLine("  " + error.Region + " " + error.Message);
                }
            }
            this.ParsedFile = this.CompilationUnit.ToTypeSystem();
        }
Пример #2
0
		public CSharpFile(CSharpProject project, string fileName)
		{
			this.Project = project;
			this.FileName = fileName;
			this.Content = new StringTextSource(File.ReadAllText(FileName));
			this.LinesOfCode = 1 + this.Content.Text.Count(c => c == '\n');
			
			CSharpParser p = project.CreateParser();
			this.CompilationUnit = p.Parse(Content.CreateReader(), fileName);
			if (p.HasErrors) {
				Console.WriteLine("Error parsing " + fileName + ":");
				foreach (var error in p.ErrorPrinter.Errors) {
					Console.WriteLine("  " + error.Region + " " + error.Message);
				}
			}
			this.ParsedFile = this.CompilationUnit.ToTypeSystem();
		}