Table::Table(int maxSize){
		this->size_ = NULL;

		if (maxSize < LT_MAX_SIZE) this->maxSize_ = maxSize;
		else throw ERROR_THROW(200);

		this->table_ = new Element[maxSize];
	}
Example #2
0
	OUT getout(wchar_t  outfile[])
	{
		static std::ofstream out;
		OUT g;
		out.open(outfile);
		if (!out.is_open())			throw ERROR_THROW(113);
		wcscpy_s(g.outfile, outfile);
		g.stream = &out;
		return g;
	}
Example #3
0
	IN getin(wchar_t infile[])
	{
		IN g = { 0, 0, 0, NULL, IN_CODE_TABLE };
		g.text = new char[IN_MAX_LEN_TEXT];
		unsigned char p;
		std::ifstream file(infile);
		int point = 0;
		if (!file.is_open())		throw ERROR_THROW(110);
		while ((p = file.get())&&(!file.eof()))
		{
			switch (g.code[p])
			{
			case IN::F:				throw ERROR_THROW_IN(111, g.lines, point);
			case IN::T: 
				point++;
				g.text[g.size] = p;
				g.size++;
				if (p == IN_CODE_ENDL)
				{
					g.lines++;
					point = 0;
				}
				break;
			case IN::I: 
				g.ignor++;
				point++;
				break;
			default:
				g.text[g.size] = g.code[p];
				g.size++;
				point++;
				break;
			}
		}
		g.text[g.size] = 0x00;
		return g;
	}
Example #4
0
	void In::execute(LOG::Log* log, wchar_t* infile){
		std::ifstream file(infile);
		ERROR::Error* errorVar;

		int clearedValue[] = IN_CODE_TABLE;
		int currChainPosition = 0;				// позиция в цепочке
		int positionCounter = 0;				// позиция в строке файла
		char tempChar;							// считываемый символ из файла
		char previousChar = 0;					// предыдущий символ, нужен для удаления пробелов

		this->setCode(clearedValue);

		if (file.good()){
			log->writeLine("---Начало проверки допустимости символов---", "");

			this->setArr(new char*[IN_MAX_LINE_NUMBER]);	// выделение памяти под кол-во строк In_MAX_LInE_NUMBER
			this->addLine(new char[IN_MAX_LEN_TEXT]);		// выделение памяти для нулевой строки, In_MAX_LEN_TEXT символов

			tempChar = file.get();

			while (!file.eof())	{
				switch (this->getCode(tempChar)){
				case IN::A:
					this->addChar(currChainPosition, tempChar);
					positionCounter++;
					break;

				case IN::D:
					this->addChar(currChainPosition, tempChar);
					errorVar = ERROR_THROW_FULL(103, NULL, this->getLinesCounter(), positionCounter);
					log->writeError(errorVar);
					positionCounter++;
					break;

				case IN::I:
					positionCounter++;
					this->increaseIgnor();
					break;

				case IN::S:
					if (currChainPosition != NULL){
						this->setLineEnd(currChainPosition);
						positionCounter = 0;
					};
 					if (tempChar == IN_CODE_ENDL){
 						this->addChar(currChainPosition, LEX_NEW_LINE);
 						this->increaseLines();
 					}
					else{
						this->addChar(currChainPosition, tempChar);
					};
					this->setLineEnd(currChainPosition);
					positionCounter = 0;
					break;

				case IN::B:
					if (this->getCode(previousChar) == IN::A){
						this->setLineEnd(currChainPosition);
						positionCounter = 0;
					};
					break;

				case IN::Q:
					this->createLine(tempChar, file, positionCounter);
					positionCounter = 0;
					currChainPosition = 0;
					break;

				case IN::C:
					if (this->getCode(previousChar) != IN::C
						&& currChainPosition != NULL){
						this->setLineEnd(currChainPosition);
						positionCounter = 0;
					};
					this->addChar(currChainPosition, tempChar);

					if (this->getCode(file.peek()) != IN::C){
						this->setLineEnd(currChainPosition);
						positionCounter = 0;
					};
					break;

				default:
					this->addChar(currChainPosition, tempChar);
					positionCounter++;
					break;
				};

				this->setText(tempChar);
				this->increaseSize();
				positionCounter++;
				previousChar = tempChar;
				tempChar = file.get();
			};

			log->writeLine("---Конец проверки допустимости символов---\n", "");
		}
		else
			throw ERROR_THROW(102);

		this->setText(NULL_STR);
		file.close();
	};