本文整理汇总了C#中Microsoft.JScript.Context.GetToken方法的典型用法代码示例。如果您正苦于以下问题:C# Context.GetToken方法的具体用法?C# Context.GetToken怎么用?C# Context.GetToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.JScript.Context
的用法示例。
在下文中一共展示了Context.GetToken方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetStateForText
public virtual SourceState GetStateForText(string sourceCode, SourceState state)
{
if (sourceCode != null)
{
this._state = SourceState.STATE_COLOR_NORMAL;
Context sourceContext = new Context(null, sourceCode);
this._scanner.SetSource(sourceContext);
if ((SourceState.STATE_COLOR_COMMENT == state) && (this._scanner.SkipMultiLineComment() > sourceCode.Length))
{
this._state = SourceState.STATE_COLOR_COMMENT;
return this._state;
}
this._scanner.GetNextToken();
JSToken none = JSToken.None;
while (sourceContext.GetToken() != JSToken.EndOfFile)
{
none = sourceContext.GetToken();
this._scanner.GetNextToken();
}
if (JSToken.UnterminatedComment == none)
{
this._state = SourceState.STATE_COLOR_COMMENT;
}
}
return this._state;
}
示例2: ColorFromToken
internal static TokenColor ColorFromToken(Context context)
{
JSToken token = context.GetToken();
if (JSScanner.IsKeyword(token))
{
return TokenColor.COLOR_KEYWORD;
}
if (JSToken.Identifier == token)
{
if (context.Equals("eval"))
{
return TokenColor.COLOR_KEYWORD;
}
return TokenColor.COLOR_IDENTIFIER;
}
if (JSToken.StringLiteral == token)
{
return TokenColor.COLOR_STRING;
}
if ((JSToken.NumericLiteral == token) || (JSToken.IntegerLiteral == token))
{
return TokenColor.COLOR_NUMBER;
}
if ((JSToken.Comment == token) || (JSToken.UnterminatedComment == token))
{
return TokenColor.COLOR_COMMENT;
}
if (JSScanner.IsOperator(token))
{
return TokenColor.COLOR_OPERATOR;
}
return TokenColor.COLOR_TEXT;
}
示例3: Colorize
public virtual ITokenEnumerator Colorize(string sourceCode, SourceState state)
{
TokenColorInfoList list = new TokenColorInfoList();
this._state = SourceState.STATE_COLOR_NORMAL;
if (sourceCode.Length > 0)
{
Context sourceContext = new Context(null, sourceCode);
this._scanner.SetSource(sourceContext);
try
{
if (SourceState.STATE_COLOR_COMMENT == state)
{
int length = this._scanner.SkipMultiLineComment();
if (length > sourceCode.Length)
{
this._state = SourceState.STATE_COLOR_COMMENT;
length = sourceCode.Length;
}
list.Add(sourceContext);
if (length == sourceCode.Length)
{
return list;
}
}
this._scanner.GetNextToken();
JSToken none = JSToken.None;
while (sourceContext.GetToken() != JSToken.EndOfFile)
{
list.Add(sourceContext);
none = sourceContext.GetToken();
this._scanner.GetNextToken();
}
if (JSToken.UnterminatedComment == none)
{
this._state = SourceState.STATE_COLOR_COMMENT;
}
}
catch (ScannerException)
{
}
}
return list;
}