本文整理汇总了C#中TokenKind.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# TokenKind.ToString方法的具体用法?C# TokenKind.ToString怎么用?C# TokenKind.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TokenKind
的用法示例。
在下文中一共展示了TokenKind.ToString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Match
private Token Match(TokenKind kind)
{
if (_lookahead.Kind == kind)
return ReadToken();
throw new ParserError(_lookahead.Position, "Expected '" + kind.ToString() + "', found '" + _lookahead.ToString() + "'");
}
示例2: Accept
private void Accept(TokenKind expected)
{
if (currentToken.Kind == expected)
{
AcceptIt();
}
else
{
SyntaxError(expected.ToString() + " expected, but "+currentToken.Kind+" was found");
}
}
示例3: Write
/// <summary>
/// 各種トークンを受け取りStringBuilderに格納します
/// </summary>
public void Write(TokenKind kind, string value)
{
switch (kind)
{
case TokenKind.None:
builder.Append(Escape(value));
break;
case TokenKind.WhiteSpace:
case TokenKind.EOL:
builder.Append(Escape(value));
break;
default:
builder.Append("<span class=\"" + kind.ToString() + "\">" + Escape(value) + "</span>");
break;
}
}
示例4: TokenKindToOperator
private OperatorKind TokenKindToOperator(Position position, TokenKind kind)
{
switch (kind)
{
case TokenKind.Asterisk: return OperatorKind.Multiplication;
case TokenKind.Backslash: return OperatorKind.Difference;
case TokenKind.Equal: return OperatorKind.Equality;
case TokenKind.GreaterThan: return OperatorKind.GreaterThan;
case TokenKind.LessThan: return OperatorKind.LessThan;
case TokenKind.Minus: return OperatorKind.Subtraction;
case TokenKind.Plus: return OperatorKind.Addition;
default: throw new ParserError(position, "Invalid operator encountered: " + kind.ToString());
}
}
示例5: TokenKindToOperatorName
private string TokenKindToOperatorName(Position position, TokenKind kind)
{
switch (kind)
{
case TokenKind.Asterisk : return "*";
case TokenKind.Backslash : return "\\";
case TokenKind.Equal : return "=";
case TokenKind.GreaterThan: return ">";
case TokenKind.LessThan : return "<";
case TokenKind.Minus : return "-";
case TokenKind.Plus : return "+";
default: throw new ParserError(position, "Invalid operator encountered: " + kind.ToString());
}
}