⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 error.h

📁 一个可视化的编译器
💻 H
字号:
/// <author> 任晶磊 </author>
/// <update> 2008-3-1 </update>
///	<E-mail> renjinglei@163.com </E-mail>

#ifndef ERROR_H
#define ERROR_H

#include <list>
#include <string>
#include <iostream>
#include <sstream>

namespace C0
{
	namespace Interpreter
	{
		using std::string;
		using std::list;

		class Error
		{
			string fileName;
			int lineNum;
			int charNum;
			string reference;
		public:
			Error(const string& fileName, int lineNum, int charNum, const string& reference)
				:fileName(fileName), lineNum(lineNum), charNum(charNum), reference(reference){}

			string ToString()
			{
				std::stringstream sstr;
				sstr << fileName << "(" << lineNum << ")";
				string location;
				sstr >> location;
				return location + " : " + reference;
			}
		};

		class ErrorLog
		{
			list<Error> errors;
		public:
			void Record(const string& fileName, int lineNum, int charNum, const string& reference)
			{
				Error error(fileName, lineNum, charNum, reference);
				errors.push_back(error);
			}
			
			bool Empty()
			{
				return errors.empty();
			}

			int Count()
			{
				return (int)errors.size();
			}

			void Print()
			{
				for (list<Error>::iterator it = errors.begin(); it != errors.end(); ++it)
				{
					std::cout << it->ToString() << std::endl;
				}
			}
		};
	}
}

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -