Nexus.Client.Util.Antlr.ErrorTracker.ToString C# (CSharp) Method

ToString() public method

Generates a string representation of the class.
This returns an error message summarizing the tracker's errors.
public ToString ( ) : string
return string
		public override string ToString()
		{
			StringBuilder stbErrors = new StringBuilder();
			if (LexerErrors.Count > 0)
			{
				stbErrors.AppendLine("Lexer Errors:");
				foreach (LanguageError lerError in LexerErrors)
					stbErrors.Append("\t").AppendLine(lerError.ToString());
				if (ParserErrors.Count > 0)
					stbErrors.AppendLine();
			}
			if (ParserErrors.Count > 0)
			{
				stbErrors.AppendLine("Parser Errors:");
				foreach (LanguageError lerError in ParserErrors)
					stbErrors.Append("\t").AppendLine(lerError.ToString());
			}
			return stbErrors.ToString();
		}

Usage Example

示例#1
0
		/// <summary>
		/// Parses the given CPL into an AST.
		/// </summary>
		/// <param name="p_strCplCode">The CPL to convert.</param>
		/// <returns>The AST built from the given CPL.</returns>
		private ITree GenerateAst(string p_strCplCode)
		{
			ErrorTracker ertErrors = new ErrorTracker();
			AntlrParserBase cpbParser = ParserFactory.CreateParser(p_strCplCode, ertErrors);
			ITree astCPL = cpbParser.Parse();
			if (ertErrors.HasErrors)
				throw new ArgumentException("Invalid CPL:" + Environment.NewLine + ertErrors.ToString(), "p_strCplCode");
			return astCPL;
		}
ErrorTracker