void CTextParser::SkipWhiteSpace(void)
{
	char	cCurrent;

	for (;;)
	{
		if (mbOutsideText)
		{
			return;
		}

		cCurrent = mszParserPos[0];

		//Nice clean white space...
		if (IsWhiteSpace(cCurrent))
		{
			StepRight();
		}

		//Possibly nasty comments...
		else if (cCurrent == '/')
		{
			StepRight();

			if (!mbOutsideText)
			{
				cCurrent = mszParserPos[0];
				if (cCurrent == '*')
				{
					//Put the parser back where it was.
					StepLeft();
					SkipCStyleComment();
				}
				else if (cCurrent == '/')
				{
					//Put the parser back where it was.
					StepLeft();
					if (!SkipCPPStyleComment())
					{
						break;
					}
				}
				else
				{
					//Was something other than white-space starting with /
					StepLeft();
					break;
				}
			}
		}
		else
		{
			//Was not white-space at all.
			break;
		}
	}
}
TRISTATE CTextParser::FindStartOfLine(void)
{
	char cCurrent;
	BOOL bInQuotes;

	PushPosition();

	//If we're off the end of the file we can't return the beginning of the line.
	if (mbOutsideText)
	{
		PopPosition();
		SetErrorEndOfFile();
		return TRIERROR;
	}

	bInQuotes = FALSE;
	for (;;)
	{
		cCurrent = mszParserPos[0];
		if (cCurrent == '"')
		{
			bInQuotes = !bInQuotes;
		}
		if (!bInQuotes)
		{
			SkipLeftCStyleComment();
		}
		StepLeft();

		//If we have no more text then the start of the line is the start of the text.
		if (mbOutsideText)
		{
			mszParserPos = mszStartOfText;
			miColumn = 0;
			PassPosition();
			return TRITRUE;
		}

		if (!bInQuotes)
		{
			//Get the current character.
			cCurrent = mszParserPos[0];

			//If we get find an end of line character we've gone to far, go right again.
			if (cCurrent == '\n')
			{
				StepRight();
				PassPosition();
				return TRITRUE;
			}
		}
	}
}
Example #3
0
/*获取鼠标消息并根据鼠标点击位置进行相应操作*/
void GetMessage(MOUSEMSG m)
{
	//鼠标循环
	switch(m.uMsg)
	{
	case WM_LBUTTONDOWN:
	case WM_LBUTTONDBLCLK:
		if(m.x>440&&m.x<460&&m.y>60&&m.y<80)
			StepUp();
		if(m.x>420&&m.x<440&&m.y>80&&m.y<100)
			StepLeft();
		if(m.x>460&&m.x<480&&m.y>80&&m.y<100)
			StepRight();
		if(m.x>440&&m.x<460&&m.y>100&&m.y<120)
			StepDown();
		break;
	default: 
		break;
	}
	return ;
}
TRISTATE CTextParser::FindWhiteSpace(void)
{
	char cCurrent;
	BOOL bStartOfComment;

	bStartOfComment = FALSE;
	for (;;)
	{
		if (mbOutsideText)
		{
			return TRIFALSE;
		}

		cCurrent = mszParserPos[0];
		if (IsWhiteSpace(cCurrent))
		{
			return TRITRUE;
		}
		if (bStartOfComment)
		{
			if ((cCurrent == '/') || (cCurrent == '*'))
			{
				StepLeft();
				return TRITRUE;
			}
		}
		if (cCurrent = '/')
		{
			bStartOfComment = TRUE;
		}
		else
		{
			bStartOfComment = FALSE;
		}
		StepRight();
	}
}
BOOL CTextParser::SkipCPPStyleComment(void)
{
	char	cCurrent;
	int		iCount;

	if (mbOutsideText)
	{
		return TRUE;
	}

	PushPosition();
	cCurrent = mszParserPos[0];

	if (cCurrent == '/')
	{
		StepRight();
		if (!mbOutsideText)
		{
			cCurrent = mszParserPos[0];
			if (cCurrent == '/')
			{
				for (iCount = 0;; iCount++)
				{
					StepRight();
					if (!mbOutsideText)
					{
						cCurrent = mszParserPos[0];

						if (cCurrent == '\n')
						{
							//This is the end of the line and the end of the comment.
							StepRight();
							PassPosition();
							return TRUE;
						}

						if (mbAnnotated)
						{
							if (cCurrent == '@')
							{
								//Wasn't a comment, was an annotation.
								PopPosition();
								return FALSE;
							}
						}
					}
					else
					{
						PassPosition();
						return TRUE;
					}
				}
			}
			else
			{
				PopPosition();
				return TRUE;
			}
		}
		else
		{
			//Wasn't a comment.
			StepLeft();
			return TRUE;
		}
	}
	PopPosition();
	return TRUE;
}
void CTextParser::SkipLeftCStyleComment(void)
{
	char	cCurrent;
	int		iDepth;

	iDepth = 0;

	PushPosition();
	for (;;)
	{
		if (mbOutsideText)
		{
			PassPosition();
			return;
		}

		cCurrent = mszParserPos[0];
		if (cCurrent == '/')
		{
			StepLeft();
			if (!mbOutsideText)
			{
				cCurrent = mszParserPos[0];
				if (cCurrent == '*')
				{
					iDepth++;
				}
				else
				{
					//Wasn't a comment start... step back.
					StepRight();
				}
			}
			else
			{
				PassPosition();
				return;
			}
		}
		else if (cCurrent == '*')
		{
			StepLeft();
			if (!mbOutsideText)
			{
				cCurrent = mszParserPos[0];
				if (cCurrent == '/')
				{
					iDepth--;
				}
				else
				{
					//Wasn't the end of a comment... step back...
					StepRight();
				}
			}
			else
			{
				PassPosition();
				return;
			}
		}

		if (iDepth == 0)
		{
			//No more nested comments...  bail..
			return;
		}
		StepLeft();
	}
}