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


C# TokenType.ToString方法代码示例

本文整理汇总了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();
		}
开发者ID:modulexcite,项目名称:stitchup,代码行数:11,代码来源:Token.cs

示例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();
        }
开发者ID:Vanlightly,项目名称:Logari,代码行数:7,代码来源:LqlParser.cs

示例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++];
 }
开发者ID:GregoryComer,项目名称:CSubCompiler,代码行数:8,代码来源:TokenStream.cs

示例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; ;
        }
开发者ID:nemcek,项目名称:notenizer,代码行数:11,代码来源:NoteParticle.cs

示例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;
     }
 }
开发者ID:GregoryComer,项目名称:CSubCompiler,代码行数:13,代码来源:Parser.cs

示例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;
     }
 }
开发者ID:OmarMoataz,项目名称:CPP-Mini-Compiler,代码行数:14,代码来源:AbstractParser.cs

示例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 ();
			}
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:24,代码来源:Token.cs

示例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);
        }
开发者ID:pksorensen,项目名称:FluentACS,代码行数:63,代码来源:ServiceManagementWrapper.cs

示例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;
     }
 }
开发者ID:rinkako,项目名称:ProjectYuri,代码行数:25,代码来源:LL1ParseMap.cs

示例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 ();
            }
开发者ID:thesecretlab,项目名称:YarnSpinner,代码行数:39,代码来源:Parser.cs

示例11: ExpectedTokenException

 public ExpectedTokenException(TokenType expectedType)
     : base("Expected token type to be " + expectedType.ToString())
 {
 }
开发者ID:marco-fiset,项目名称:migraine,代码行数:4,代码来源:TokenStream.cs

示例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;
 }
开发者ID:rslijp,项目名称:sharptiles,代码行数:9,代码来源:ParseHelper.cs

示例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;
        }
开发者ID:Vanlightly,项目名称:Logari,代码行数:7,代码来源:TokenBasedErrorParser.cs

示例14: RaiseQueryInvalidTerminatedError

 private void RaiseQueryInvalidTerminatedError(TokenType expected, string innerQuery)
 {
     throw new FilterQueryException("Query is terminated in halfway. Next token is expected: " + expected.ToString(), innerQuery);
 }
开发者ID:azyobuzin,项目名称:StarryEyes,代码行数:4,代码来源:TokenReader.cs

示例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;
        }
开发者ID:Mgamerz,项目名称:ME3Libs,代码行数:27,代码来源:ClassOutlineParser.cs


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