当前位置: 首页>>代码示例>>C++>>正文


C++ CLanguageProxy::IsKeyword方法代码示例

本文整理汇总了C++中CLanguageProxy::IsKeyword方法的典型用法代码示例。如果您正苦于以下问题:C++ CLanguageProxy::IsKeyword方法的具体用法?C++ CLanguageProxy::IsKeyword怎么用?C++ CLanguageProxy::IsKeyword使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CLanguageProxy的用法示例。


在下文中一共展示了CLanguageProxy::IsKeyword方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

_EXPORT void ColorLine(CLanguageProxy& proxy, int32& state)
{
	const char *text = proxy.Text();
	int32 size = proxy.Size();
	int32 i = 0, s = 0, kws = 0, esc = 0;
	char c = 0;
	bool leave = false;

	if (state == LCOMMENT)
		proxy.SetColor(0, kColorComment1);
	else
		proxy.SetColor(0, kColorText);

	if (size <= 0)
		return;

	while (!leave)
	{
		char b = c;
		GETCHAR;

		switch (state) {
			case START:
				if (c == '#' && (!b || isspace(b)))
					state = LCOMMENT;
				else if (isalpha(c) || c == '_')
				{
					kws = proxy.Move(c, 1);
					state = IDENT;
				}
				else if (c == '"')
					state = STRING1;
				else if (c == '\'')
					state = STRING2;
				else if (c == '\n' || c == 0)
					leave = true;

				if (leave || (state != START && s < i))
				{
					proxy.SetColor(s, kColorText);
					s = i - 1;
				}
				break;

			case LCOMMENT:
				proxy.SetColor(s, kColorComment1);
				leave = true;
				if (text[size - 1] == '\n')
					state = START;
				break;

			case IDENT:
				if (!isalnum(c) && c != '_')
				{
					int kwc;

					if (i >= s + 1 && (kwc = proxy.IsKeyword(kws)) != 0)
					{
						switch (kwc)
						{
							case 1:	proxy.SetColor(s, kColorKeyword1); break;
							case 2:	proxy.SetColor(s, kColorUserSet1); break;
							case 3:	proxy.SetColor(s, kColorUserSet2); break;
							case 4:	proxy.SetColor(s, kColorUserSet3); break;
							case 5:	proxy.SetColor(s, kColorUserSet4); break;
//							default:ASSERT(false);
						}
					}
					else
					{
						proxy.SetColor(s, kColorText);
					}

					s = --i;
					state = START;
				}
				else if (kws)
					kws = proxy.Move((int)(unsigned char)c, kws);
				break;

			case STRING1:
				if (c == '"' && !esc)
				{
					proxy.SetColor(s, kColorString1);
					s = i;
					state = START;
				}
				else if (c == '\n' || c == 0)
				{
					if (text[i - 2] == '\\' && text[i - 3] != '\\')
					{
						proxy.SetColor(s, kColorString1);
					}
					else
					{
						proxy.SetColor(s, kColorText);
						state = START;
					}

					s = size;
//.........这里部分代码省略.........
开发者ID:HaikuArchives,项目名称:Pe,代码行数:101,代码来源:Recipe_Language.cpp

示例2: if

_EXPORT void ColorLine(CLanguageProxy& proxy, int32& state)
{
	const char *text = proxy.Text();
	int32 size = proxy.Size();
	int32 i = 0, s = 0, kws = 0, cc_cnt = 0, esc = 0;
	char c;
	bool leave = false;

	if (state == COMMENT || state == LCOMMENT)
		proxy.SetColor(0, kColorComment1);
	else
		proxy.SetColor(0, kColorText);

	if (size <= 0)
		return;

	while (!leave)
	{
		GETCHAR;

		switch (state) {
			case START:
				if (isalpha(c) || c == '_')
				{
					kws = proxy.Move(c, 1);
					state = IDENT;
				}
				else if (c == '/' && text[i] == '*')
					state = COMMENT;
				else if (c == '/' && text[i] == '/')
					state = LCOMMENT;
				else if (c == '"')
					state = STRING;
				else if (c == '\'')
				{
					state = CHAR_CONST;
					cc_cnt = 0;
				}
				else if (c == '\n' || c == 0)
					leave = true;

				if (leave || (state != START && s < i))
				{
					proxy.SetColor(s, kColorText);
					s = i - 1;
				}
				break;

			case COMMENT:
				if ((s == 0 || i > s + 1) && c == '*' && text[i] == '/')
				{
					proxy.SetColor(s, kColorComment1);
					s = i + 1;
					state = START;
				}
				else if (c == 0 || c == '\n')
				{
					proxy.SetColor(s, kColorComment1);
					leave = true;
				}
				break;

			case LCOMMENT:
				proxy.SetColor(s, kColorComment1);
				leave = true;
				if (text[size - 1] == '\n')
					state = START;
				break;

			case IDENT:
				if (!isalnum(c) && c != '_' && c != '.')
				{
					int32 kwc;

					if (i > s + 1 && (kwc = proxy.IsKeyword(kws)) != 0)
					{
						switch (kwc)
						{
							case 1:	proxy.SetColor(s, kColorKeyword1); break;
							case 2:	proxy.SetColor(s, kColorUserSet1); break;
							case 3:	proxy.SetColor(s, kColorUserSet2); break;
							case 4:	proxy.SetColor(s, kColorUserSet3); break;
							case 5:	proxy.SetColor(s, kColorUserSet4); break;
//							default:	ASSERT(false);
						}
					}
					else
					{
						proxy.SetColor(s, kColorText);
					}

					s = --i;
					state = START;
				}
				else if (kws)
					kws = proxy.Move((int)(unsigned char)c, kws);
				break;

			case STRING:
				if (c == '"' && !esc)
//.........这里部分代码省略.........
开发者ID:HaikuArchives,项目名称:Pe,代码行数:101,代码来源:Java_Language.cpp

示例3: if

_EXPORT void ColorLine(CLanguageProxy& proxy, int32& state)
{
	const char *text = proxy.Text();
	int32 size = proxy.Size();
	int32 i = 0, s = 0, kws = 0, esc = 0;
	char c;
	bool leave = false;

	if (state == LCOMMENT)
		proxy.SetColor(0, kColorComment1);
	else
		proxy.SetColor(0, kColorText);

	if (size <= 0)
		return;

	while (!leave)
	{
		GETCHAR;
		if (c == '`')
		{
			GETCHAR;
			c = ' ';
		}

		switch (state)
		{
			case START:
				if (c == '\\')
					state = COMMAND1;
				else if (c == '%')
					state = LCOMMENT;
				else if (c == '$')
					state = MATH;
				else if (c == '\n' || c == 0)
					leave = true;
				else if (isalnum(c))
					state = WORD;
                /* This is a bit strange to have some of the characters covered above, but who cares?*/
				else if (c == '#' || c == '&'
						|| c == '~' || c == '_' || c == '^'
						|| c == '{' || c == '}'
						|| c == '[' || c == ']'
						)
					state = CONSTCHAR;

				if ((leave || state != START) && s < i)
				{
					proxy.SetColor(s, kColorText);
					s = i - 1;
				}
				break;

			case CONSTCHAR:
				proxy.SetColor(s, kColorCharConst);
				s = --i;
				state = START;
				break;

			case WORD:
				if (!isalnum(c))
				{
					proxy.SetColor(s, kColorText);
					s = --i;
					state = START;
				}
				break;

			case LCOMMENT:
				proxy.SetColor(s, kColorComment1);
				leave = true;
				if (text[size - 1] == '\n')
					state = START;
				break;

			case COMMAND1:
                                     if (c=='('){
                                              state = MATH;
                                     } else if ((isalnum(c)) || (c=='@'))   /* a generic command has been found. */
			    /* Note that commands with "@" in their name only appear in .cls or .sty files */
                                     {
					kws = proxy.Move(c, 1);
					state = COMMAND2;
				}
				else   /* we are escaping a special text character such as \# or \$*/
				{
					proxy.SetColor(s, kColorText);
					s = i;
					state = START;
				}
				break;

			case COMMAND2:    /* Inside the name of a generic command */
				if (!(isalnum(c)) && !(c=='@')) /* found end of command name */
				{      /* now check the command name against a keyword list */
					int kwc;

					if (i > s + 1 && (kwc = proxy.IsKeyword(kws)) != 0)
					{
						switch (kwc)
//.........这里部分代码省略.........
开发者ID:HaikuArchives,项目名称:Pe,代码行数:101,代码来源:Tex_Language.cpp

示例4: if


//.........这里部分代码省略.........
				}
				else if (!isspace(c))
				{
					nxt--;
					state = TAG;
				}
				break;

			case TAG_KEYWORD_END:
				DEB_PrintState(state, c);
				if (isalpha(c))
				{
					proxy.SetColor(beg, kColorTag);
					beg = nxt-1;
					kws = proxy.Move(CASE_SENSITIVE_TAG ? c : tolower(c), 1);
					state = TAG_KEYWORD_START;
				}
				else if (c == 0 || c == '\n')
				{
					proxy.SetColor(beg, kColorTag);
					leave = true;
				}
				else if (!isspace(c))
				{
					nxt--;
					state = TAG;
				}
				break;

			case TAG_KEYWORD_START:
				DEB_PrintState(state, c);
				if (!isalnum(c) && c != '-')
				{
					switch (kwc = proxy.IsKeyword(kws, kKwHtmlTag|kKwUsersets))
					{
						case kKwHtmlTag:  color = kColorTag;      break;
						case kKwUserset1: color = kColorUserSet1; break;
						case kKwUserset2: color = kColorUserSet2; break;
						case kKwUserset3: color = kColorUserSet3; break;
						case kKwUserset4: color = kColorUserSet4; break;
						default:          color = kColorText;     break;
					}
					proxy.SetColor(beg, color);
					DEB_PrintSetKw(state, kwc);

					if (text[beg-1] != '/')
					{
						if (strncasecmp(text+beg, "script", 6) == 0)
							script = true;
						else if (strncasecmp(text+beg, "style", 5) == 0)
							style = true;
					}
					state = TAG;
					beg = --nxt;
				}
				else if (kws)
					kws = proxy.Move(CASE_SENSITIVE_TAG ? c : tolower(c), kws);
				break;

			case TAG:
				DEB_PrintState(state, c);
				switch (c)
				{
					case 0:
					case '\n':
						proxy.SetColor(beg, kColorTag);
开发者ID:HaikuArchives,项目名称:Pe,代码行数:67,代码来源:HtmlCssJsPhp_Language.cpp

示例5: if


//.........这里部分代码省略.........
			case JSTAGSTRING1:
				if (c == '"')
				{
					proxy.SetColor(s, kColorString2);
					s = i;
					state--; // TAG
				}
				else if (c == '\n' || c == 0)
				{
					proxy.SetColor(s, kColorString2);
					leave = true;
				}
				break;

			case TAGSTRING2:
			case JSTAGSTRING2:
				if (c == '\'')
				{
					proxy.SetColor(s, kColorString2);
					s = i;
					state -= 2; // TAG
				}
				else if (c == '\n' || c == 0)
				{
					proxy.SetColor(s, kColorString2);
					leave = true;
				}
				break;

			case TAGKEYWORD:
			case JSTAGKEYWORD:
				if (! isalnum(c))
				{
					switch (proxy.IsKeyword(kws))
					{
						case 1:	 proxy.SetColor(s, kColorKeyword1); break;
						case 2:	 proxy.SetColor(s, kColorUserSet1); break;
						case 3:	 proxy.SetColor(s, kColorUserSet2); break;
						case 4:	 proxy.SetColor(s, kColorUserSet3); break;
						case 5:	 proxy.SetColor(s, kColorUserSet4); break;
						default: proxy.SetColor(s, kColorTag);      break;
					}

					if (strncasecmp(text + s, "SCRIPT", 6) == 0)
					{
						if (state == TAGKEYWORD)
							state += JAVASCRIPT;
						else
							state -= JAVASCRIPT;
					}

					s = --i;
					state -= 3;	// TAG
				}
				else if (kws)
					kws = proxy.Move(tolower(c), kws);
				break;

			case SPECIAL:
			case JSSPECIAL:
				if (c == 0 || c == '\n')
				{
					proxy.SetColor(s, kColorText);
					state = START;
					leave = true;
				}
开发者ID:HaikuArchives,项目名称:Pe,代码行数:67,代码来源:HtmlJs_Language.cpp

示例6: if

_EXPORT void ColorLine(CLanguageProxy& proxy, int& state)
{
	const char *text = proxy.Text();
	int size = proxy.Size();
	int i = 0, s = 0, kws = 0, esc = 0;
	char c, mc = 0;
	bool leave = false;
	
	if (state == COMMENT || state == LCOMMENT)
		proxy.SetColor(0, kColorComment1);
	else
		proxy.SetColor(0, kColorText);
	
	if (size <= 0)
		return;
	
	while (!leave)
	{
		GETCHAR;
		
		switch (state) {
			case START:
				if (c == '#' && text[i - 2] != '$')
					state = LCOMMENT;
				else if (isalpha(c) || c == '_')
				{
					kws = proxy.Move(c, 1);
					state = IDENT;
				}
				else if (c == '"')
					state = STRING1;
				else if (c == '\'')
					state = STRING2;
				else if (c == '&')
					state = SCOPE;
				else if (c == '$')
				{
					if (isalpha(text[i]) || text[i] == '#')
					{
						i++;
						state = VAR;
					}
					else
					{
						i++;
						proxy.SetColor(s, kColorText);
						s = i;
					}
				}
				else if (c == '@' || c == '*')
					state = VAR;
				else if (c == '/')
				{
					mc = '/';
					state = REGEX1;
				}
				else if (c == '\n' || c == 0)
					leave = true;
					
				if (leave || (state != START && s < i))
				{
					proxy.SetColor(s, kColorText);
					s = i - 1;
				}
				break;
			
			case LCOMMENT:
				proxy.SetColor(s, kColorComment1);
				leave = true;
				if (text[size - 1] == '\n')
					state = START;
				break;
			
			case IDENT:
				if (!isalnum(c) && c != '_')
				{
					int kwc;

					if (i >= s + 1 && (kwc = proxy.IsKeyword(kws)) != 0)
					{
						switch (kwc)
						{
							case 1:	proxy.SetColor(s, kColorKeyword1); break;
							case 2:	proxy.SetColor(s, kColorUserSet1); break;
							case 3:	proxy.SetColor(s, kColorUserSet2); break;
							case 4:	proxy.SetColor(s, kColorUserSet3); break;
							case 5:	proxy.SetColor(s, kColorUserSet4); break;
//							default:ASSERT(false);
						}
					}
					else
					{
						proxy.SetColor(s, kColorText);
					}
					
					if (i == s + 2)
					{
						switch (*(text + s))
						{
							case 'm': state = REGEX1; break;
//.........这里部分代码省略.........
开发者ID:jscipione,项目名称:Paladin,代码行数:101,代码来源:Perl_Language.cpp

示例7: if


//.........这里部分代码省略.........
				{
					state = SYMBOL;
				}
				else if (c == '\n' || c == 0)
					leave = true;
				break;
			
			case COMMENT:
				if ((s == 0 || i > s + 1) && c == '*' && text[i] == '/')
				{
					proxy.SetColor(s, kColorComment1);
					i++;
					state = START;
				}
				else if (c == 0 || c == '\n')
				{
					proxy.SetColor(s, kColorComment1);
					leave = true;
				}
				break;

			case LCOMMENT:
				proxy.SetColor(s, kColorComment1);
				leave = true;
				if (text[size - 1] == '\n')
					state = START;
				break;
			
			case IDENT:
				if (!isalnum(c) && c != '_')
				{
					int kwc;

					if (i > s + 1 && (kwc = proxy.IsKeyword(kws)) != 0)
					{
						switch (kwc)
						{
							case 1:	proxy.SetColor(s, kColorKeyword1); break;
							case 2:	proxy.SetColor(s, kColorUserSet1); break;
							case 3:	proxy.SetColor(s, kColorUserSet2); break;
							case 4:	proxy.SetColor(s, kColorUserSet3); break;
							case 5:	proxy.SetColor(s, kColorUserSet4); break;
//							default:	ASSERT(false);
						}
					}
					else
						proxy.SetColor(s, kColorText);
					
					i--;
					state = START;
				}
				else if (kws)
					kws = proxy.Move((int)(unsigned char)c, kws);
				break;
			
			case PRAGMA1:
				if (c == ' ' || c == '\t')
					;
				else if (islower(c))
				{
					kws = proxy.Move((int)(unsigned char)c, kws);
					state = PRAGMA2;
				}
				else
				{
					proxy.SetColor(s, kColorText);
开发者ID:jscipione,项目名称:Paladin,代码行数:67,代码来源:Cpp_Language.cpp

示例8: if

_EXPORT void ColorLine(CLanguageProxy& proxy, int32& state)
{
	const char *text = proxy.Text();
	int32 size = proxy.Size();
	int32 i = 0, s = 0, kws = 0, esc = 0;
	char c;
	bool leave = false;
	bool floating_point = false;
	bool hex_num = false;

//    int sqrBraquetStrCount = 0;

	if (state == LCOMMENT)
		proxy.SetColor(0, kColorComment1);
	else
		proxy.SetColor(0, kColorText);

	if (size <= 0)
		return;

	while (!leave)
	{
		GETCHAR;

		switch (state) {
			case START:
				if (isalpha(c) || c == '_')
				{
					kws = proxy.Move(tolower(c), 1);
					state = IDENT;
				}
				else if (c == '-' && text[i] == '-')
				{
					i++;
					state = LCOMMENT;
				}
				else if (c == '"')
					state = STRING;
				else if (c == '\'')
					state = STRING2;
/*
				else if (c == '[' && text[i] == '[')
				{
					sqrBraquetStrCount++;
					state = STRING3;
				}
*/
				else if (isNumeric(c) || (c == '$' && isHexNum(text[i])))
				{
					state = NUMERIC;
				}
				else if (isOperator(c))
				{
					state = OPERATOR;
				}
				else if (isSymbol(c))
				{
					state = SYMBOL;
				}
				else if (c == '\n' || c == 0)
					leave = true;

				if (leave || (state != START && s < i))
				{
					proxy.SetColor(s, kColorText);
					s = i - 1;
				}
			break;

			// -- format comments
			case LCOMMENT:
				proxy.SetColor(s - 1, kColorComment1);
				leave = true;
				if (text[size - 1] == '\n')
					state = START;
			break;

			case IDENT:
				if (!isalnum(c) && c != '_')
				{
					int32 kwc;

					if (i > s + 1 && (kwc = proxy.IsKeyword(kws)) != 0)
					{
						switch (kwc)
						{
							case 1:	proxy.SetColor(s, kColorKeyword1); break;
							case 2:	proxy.SetColor(s, kColorUserSet1); break;
							case 3:	proxy.SetColor(s, kColorUserSet2); break;
							case 4:	proxy.SetColor(s, kColorUserSet3); break;
							case 5:	proxy.SetColor(s, kColorUserSet4); break;
						}
						s = --i;
						state = START;
					}
					else
					{
						proxy.SetColor(s, kColorText);
						s = --i;
						state = START;
//.........这里部分代码省略.........
开发者ID:HaikuArchives,项目名称:Pe,代码行数:101,代码来源:Lua_Language.cpp


注:本文中的CLanguageProxy::IsKeyword方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。