PageRenderTime 8ms CodeModel.GetById 1ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/NRefactory/ICSharpCode.NRefactory.VB/Parser/Errors.cs

http://github.com/icsharpcode/ILSpy
C# | 50 lines | 40 code | 8 blank | 2 comment | 0 complexity | a1b8d17b533d66f710f06a7d3f2d265a MD5 | raw file
 1// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
 2// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
 3
 4using System;
 5using System.Text;
 6
 7namespace ICSharpCode.NRefactory.VB.Parser
 8{
 9	public delegate void ErrorCodeProc(int line, int col, int n);
10	public delegate void ErrorMsgProc(int line, int col, string msg);
11	
12	public class Errors
13	{
14		int count = 0;  // number of errors detected
15		public ErrorCodeProc SynErr;
16		public ErrorCodeProc SemErr;
17		public ErrorMsgProc  Error;
18		StringBuilder errorText = new StringBuilder();
19		
20		public string ErrorOutput {
21			get {
22				return errorText.ToString();
23			}
24		}
25		
26		public Errors()
27		{
28			SynErr = new ErrorCodeProc(DefaultCodeError);  // syntactic errors
29			SemErr = new ErrorCodeProc(DefaultCodeError);  // semantic errors
30			Error  = new ErrorMsgProc(DefaultMsgError);    // user defined string based errors
31		}
32		
33		public int Count {
34			get {
35				return count;
36			}
37		}
38		
39		void DefaultCodeError(int line, int col, int n)
40		{
41			errorText.AppendLine(String.Format("-- line {0} col {1}: error {2}", line, col, n));
42			count++;
43		}
44	
45		void DefaultMsgError(int line, int col, string s) {
46			errorText.AppendLine(String.Format("-- line {0} col {1}: {2}", line, col, s));
47			count++;
48		}
49	} // Errors
50}