本文整理汇总了C#中TokenType.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# TokenType.ToString方法的具体用法?C# TokenType.ToString怎么用?C# TokenType.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TokenType
的用法示例。
在下文中一共展示了TokenType.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetString
public static string GetString(TokenType type)
{
FieldInfo fi = typeof (TokenType).GetField(type.ToString());
object[] descriptionAttrs = fi.GetCustomAttributes(typeof (DescriptionAttribute), false);
if (descriptionAttrs.Length > 0)
{
DescriptionAttribute description = (DescriptionAttribute) descriptionAttrs[0];
return description.Description;
}
return type.ToString();
}
示例2: DiscardToken
private void DiscardToken(TokenType tokenType)
{
if (_lookaheadFirst.TokenType != tokenType)
throw new LqlParserException(string.Format("Expected {0} but found: {1}", tokenType.ToString().ToUpper(), _lookaheadFirst.Value));
DiscardToken();
}
示例3: Expect
public Token Expect(TokenType type)
{
if (_tokens[_index].Type != type)
throw new ParserException(
$"Unexpected token \"{_tokens[_index].Literal}\", expected token of type \"{type.ToString()}\".",
_index, _tokens[_index]);
return _tokens[_index++];
}
示例4: NoteParticle
public NoteParticle(NotenizerDependency dependency, TokenType tokenType, bool considerRelationInWordValueMaking = false)
{
if (tokenType == TokenType.Unidentified)
throw new Exception("Can't make NoteParticle from token of type " + tokenType.ToString());
_tokenType = tokenType;
_noteDependency = dependency.Clone();
_noteDependency.TokenType = tokenType;
_noteWord = _tokenType == TokenType.Dependent ? dependency.Dependent : dependency.Governor;
_noteWordValue = considerRelationInWordValueMaking ? MakeWordConsiderRelation(_noteWord, _noteDependency.Relation) : _noteWord.Word; ;
}
示例5: Expect
public static Token Expect(Token[] tokens, ref int i, TokenType type)
{
if (tokens[i].Type != type) //Throw exception if token type does not match expected
{
throw new ParserException(string.Format("Expected token of type {0}.", type.ToString()), i, tokens[i]);
}
else //Consume token
{
Token t = tokens[i];
i++;
return t;
}
}
示例6: Match
protected bool Match(TokenType TokenType)
{
if (Lookahead.Type == TokenType)
{
if (MoreTokens())
Lookahead = NextToken();
return true;
}
else
{
throw new ParseException("Expected " + " " + TokenType.ToString());
return false;
}
}
示例7: TypeAsString
public static string TypeAsString (TokenType tokenType)
{
switch (tokenType) {
case TokenType.Item:return "@";
case TokenType.Property:return "$";
case TokenType.Metadata:return "%";
case TokenType.Transform:return "->";
case TokenType.Less:return "<";
case TokenType.Greater:return ">";
case TokenType.LessOrEqual:return "<=";
case TokenType.GreaterOrEqual:return ">=";
case TokenType.Equal:return "=";
case TokenType.NotEqual:return "!=";
case TokenType.LeftParen:return "(";
case TokenType.RightParen:return ")";
case TokenType.Dot:return ".";
case TokenType.Comma:return ",";
case TokenType.Not:return "!";
case TokenType.And:return "and";
case TokenType.Or:return "or";
case TokenType.Apostrophe:return "'";
default: return tokenType.ToString ();
}
}
示例8: CreateRelyingParty
private static void CreateRelyingParty(ManagementService client, string relyingPartyName, string ruleGroupName, string realmAddress, string replyAddress, TokenType tokenType, int tokenLifetime, bool asymmetricTokenEncryptionRequired, out RelyingParty relyingParty)
{
// Create Relying Party
relyingParty = new RelyingParty
{
Name = relyingPartyName,
DisplayName = relyingPartyName,
Description = relyingPartyName,
TokenType = tokenType.ToString(),
TokenLifetime = tokenLifetime,
AsymmetricTokenEncryptionRequired = asymmetricTokenEncryptionRequired
};
client.AddObject("RelyingParties", relyingParty);
client.SaveChanges();
if (!string.IsNullOrWhiteSpace(ruleGroupName))
{
RuleGroup ruleGroup = client.RuleGroups.Where(rg => rg.Name.Equals(ruleGroupName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
if (ruleGroup == null)
{
ruleGroup = new RuleGroup
{
Name = ruleGroupName
};
client.AddToRuleGroups(ruleGroup);
client.SaveChanges();
}
var relyingPartyRuleGroup = new RelyingPartyRuleGroup
{
RuleGroupId = ruleGroup.Id,
RelyingParty = relyingParty
};
client.AddRelatedObject(relyingParty, "RelyingPartyRuleGroups", relyingPartyRuleGroup);
}
// Create the Realm for Relying Party
var realm = new RelyingPartyAddress
{
Address = realmAddress,
EndpointType = RelyingPartyAddressEndpointType.Realm.ToString(),
RelyingParty = relyingParty
};
client.AddRelatedObject(relyingParty, "RelyingPartyAddresses", realm);
if (!string.IsNullOrEmpty(replyAddress))
{
var reply = new RelyingPartyAddress
{
Address = replyAddress,
EndpointType = RelyingPartyAddressEndpointType.Reply.ToString(),
RelyingParty = relyingParty
};
client.AddRelatedObject(relyingParty, "RelyingPartyAddresses", reply);
}
client.SaveChanges(SaveChangesOptions.Batch);
}
示例9: GetCFunction
/// <summary>
/// 取得节点的处理函数
/// </summary>
/// <param name="left">语法类型</param>
/// <param name="leave">Token类型</param>
/// <param name="nilserver">空节点展开式处理函数</param>
/// <returns>候选式实例</returns>
public CandidateFunction GetCFunction(SyntaxType left, TokenType leave, iHandle nilserver)
{
try
{
if (left == SyntaxType.epsilonLeave)
{
return new CandidateFunction(nilserver, CFunctionType.umi_epsilon);
}
CandidateFunction candidator = this.GetCFunction(this.leftNodesDict[left], this.nextLeavesDict[leave]);
return candidator == null ? new CandidateFunction(null, CFunctionType.umi_errorEnd) : candidator;
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
Console.WriteLine(String.Format("{0} --> {1}", left.ToString(), leave.ToString()));
throw;
}
}
示例10: InfoForOperator
internal static OperatorInfo InfoForOperator(TokenType op)
{
if (Array.IndexOf(operatorTypes, op) == -1) {
throw new ParseException (op.ToString () + " is not a valid operator");
}
// Determine the precendence, associativity and
// number of operands that each operator has.
switch (op) {
case TokenType.Not:
case TokenType.UnaryMinus:
return new OperatorInfo (Associativity.Right, 30, 1);
case TokenType.Multiply:
case TokenType.Divide:
return new OperatorInfo(Associativity.Left, 20,2);
case TokenType.Add:
case TokenType.Minus:
return new OperatorInfo(Associativity.Left, 15,2);
case TokenType.GreaterThan:
case TokenType.LessThan:
case TokenType.GreaterThanOrEqualTo:
case TokenType.LessThanOrEqualTo:
return new OperatorInfo(Associativity.Left, 10,2);
case TokenType.EqualTo:
case TokenType.EqualToOrAssign:
case TokenType.NotEqualTo:
return new OperatorInfo(Associativity.Left, 5,2);
case TokenType.And:
return new OperatorInfo(Associativity.Left, 4,2);
case TokenType.Or:
return new OperatorInfo(Associativity.Left, 3,2);
case TokenType.Xor:
return new OperatorInfo(Associativity.Left, 2,2);
}
throw new InvalidOperationException ();
}
示例11: ExpectedTokenException
public ExpectedTokenException(TokenType expectedType)
: base("Expected token type to be " + expectedType.ToString())
{
}
示例12: Expect
public Token Expect(TokenType type)
{
Token current = Current;
if (!current.Type.Equals(type))
{
throw ParseException.ExpectedToken(type.ToString(), current.Contents).Decorate(current);
}
return current;
}
示例13: ReadToken
private ErrorToken ReadToken(TokenType tokenType)
{
if (_lookaheadFirst.TokenType != tokenType)
throw new ErrorParserException(string.Format("Expected {0} but found: {1}", tokenType.ToString().ToUpper(), _lookaheadFirst.Value));
return _lookaheadFirst;
}
示例14: RaiseQueryInvalidTerminatedError
private void RaiseQueryInvalidTerminatedError(TokenType expected, string innerQuery)
{
throw new FilterQueryException("Query is terminated in halfway. Next token is expected: " + expected.ToString(), innerQuery);
}
示例15: ParseScopedTokens
//TODO: unused?
private List<Token<String>> ParseScopedTokens(TokenType scopeStart, TokenType scopeEnd)
{
var scopedTokens = new List<Token<String>>();
if (Tokens.ConsumeToken(scopeStart) == null)
{
Log.LogError("Expected '" + scopeStart.ToString() + "'!", CurrentPosition, CurrentPosition.GetModifiedPosition(0, 1, 1));
return null;
}
int nestedLevel = 1;
while (nestedLevel > 0)
{
if (CurrentTokenType == TokenType.EOF)
return null; // ERROR: Scope ended prematurely, are your scopes unbalanced?
if (CurrentTokenType == scopeStart)
nestedLevel++;
else if (CurrentTokenType == scopeEnd)
nestedLevel--;
scopedTokens.Add(Tokens.CurrentItem);
Tokens.Advance();
}
// Remove the ending scope token:
scopedTokens.RemoveAt(scopedTokens.Count - 1);
return scopedTokens;
}