當前位置: 首頁>>代碼示例>>C#>>正文


C# Parser.Token類代碼示例

本文整理匯總了C#中NVelocity.Runtime.Parser.Token的典型用法代碼示例。如果您正苦於以下問題:C# Token類的具體用法?C# Token怎麽用?C# Token使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Token類屬於NVelocity.Runtime.Parser命名空間,在下文中一共展示了Token類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ParseException

 /// <summary> This constructor is used by the method "generateParseException"
 /// in the generated parser.  Calling this constructor generates
 /// a new object of this type with the fields "currentToken",
 /// "expectedTokenSequences", and "tokenImage" set.  The boolean
 /// flag "specialConstructor" is also set to true to indicate that
 /// this constructor was used to create this object.
 /// This constructor calls its super class with the empty string
 /// to force the "toString" method of parent class "Throwable" to
 /// print the error message in the form:
 /// ParseException: &lt;result of getMessage&gt;
 /// </summary>
 public ParseException(Token currentTokenVal, int[][] expectedTokenSequencesVal, String[] tokenImageVal)
     : base(string.Empty)
 {
     specialConstructor = true;
     currentToken = currentTokenVal;
     expectedTokenSequences = expectedTokenSequencesVal;
     tokenImage = tokenImageVal;
 }
開發者ID:rasmus-toftdahl-olesen,項目名稱:NVelocity,代碼行數:19,代碼來源:ParseException.cs

示例2: Directive

		/// <summary>   Supports the Pluggable Directives
		/// #foo( arg+ )
		/// </summary>
		public SimpleNode Directive()
		{
			ASTDirective directiveNode = new ASTDirective(this, ParserTreeConstants.DIRECTIVE);

			bool isNodeScopeOpen = true;
			nodeTree.OpenNodeScope(directiveNode);
			Token token;
			Directive directive;
			bool doItNow = false;

			try
			{
				/*
				* note that if we were escaped, that is now handled by 
				* EscapedDirective()
				*/
				token = ConsumeToken(ParserConstants.WORD);
				String directiveName = token.Image.Substring(1);

				directive = directives.Create(directiveName, directiveStack);

				Debug.Assert(directiveNode != null);

				directiveNode.Directive = directive;

				/*
				*  Velocimacro support : if the directive is macro directive
				*   then set the flag so after the block parsing, we add the VM
				*   right then. (So available if used w/in the current template )
				*/

				if (directiveName.Equals("macro"))
				{
					doItNow = true;
				}

				/*
				* set the directive name from here.  No reason for the thing to know 
				* about parser tokens
				*/

				directiveNode.DirectiveName = directiveName;

				DirectiveType directiveType;
				if (directive == null)
				{
					// if null, then not a real directive, but maybe a Velocimacro

					//d  =  (Directive) runtimeServices.getVelocimacro( directiveName, currentTemplateName );

					// TODO: adding a null check since RuntimeServices is not finished
					// since the parser can be created without RuntimeServices - this may actually be needed here and in the orgiginal source as well.
					if (runtimeServices != null)
					{
						if (!runtimeServices.IsVelocimacro(directiveName, currentTemplateName))
						{
							token_source.StateStackPop();
							token_source.inDirective = false;
							if (true)
								return directiveNode;
						}
					}

					/*
					 *  Currently, all VMs are LINE directives
					 */
					directiveType = DirectiveType.LINE;
				}
				else
				{
					directiveType = directive.Type;
				}

				/*
				*  now, switch us out of PRE_DIRECTIVE
				*/

				token_source.SwitchTo(ParserConstants.DIRECTIVE);

				ConsumeWhiteSpaces();

				if (directive != null && !directive.AcceptParams)
				{
					int curToken = GetCurrentTokenKind();

					if (curToken == ParserConstants.NEWLINE)
					{
						ConsumeToken(ParserConstants.NEWLINE);
					}
					else
					{
						throw new ParseException(
							"Foreach directives must be the only items on the line (comments or contents are not allowed)");
					}
				}

				if (directive == null || directive.AcceptParams)
//.........這裏部分代碼省略.........
開發者ID:rambo-returns,項目名稱:MonoRail,代碼行數:101,代碼來源:Parser.cs

示例3: ScanToken

		private bool ScanToken(int kind)
		{
			if (jj_scanpos == jj_lastpos)
			{
				jj_la--;
				if (jj_scanpos.Next == null)
				{
					jj_lastpos = jj_scanpos = jj_scanpos.Next = token_source.NextToken;
				}
				else
				{
					jj_lastpos = jj_scanpos = jj_scanpos.Next;
				}
			}
			else
			{
				jj_scanpos = jj_scanpos.Next;
			}
			if (jj_rescan)
			{
				int i = 0;
				Token tok = token;
				while(tok != null && tok != jj_scanpos)
				{
					i++;
					tok = tok.Next;
				}
				if (tok != null)
				{
					AddErrorToken(kind, i);
				}
			}
			return (jj_scanpos.Kind != kind);
		}
開發者ID:rambo-returns,項目名稱:MonoRail,代碼行數:34,代碼來源:Parser.cs

示例4: ReInit

		public void ReInit(ParserTokenManager tm)
		{
			token_source = tm;
			token = new Token();
			jj_ntk_Renamed_Field = -1;
			nodeTree.Reset();
			jj_gen = 0;
			for(int i = 0; i < 53; i++)
				jj_la1[i] = -1;
			for(int i = 0; i < callsArray.Length; i++)
				callsArray[i] = new Calls();
		}
開發者ID:rambo-returns,項目名稱:MonoRail,代碼行數:12,代碼來源:Parser.cs

示例5: jj_3R_60

		private bool jj_3R_60()
		{
			Token xsp = jj_scanpos;
			if (jj_3R_50(jj_3R_81()))
			{
				jj_scanpos = xsp;
				if (jj_3R_50(jj_3R_82()))
					return true;
				if (ToRefactor1())
					return false;
			}
			else if (ToRefactor1())
				return false;
			return false;
		}
開發者ID:rambo-returns,項目名稱:MonoRail,代碼行數:15,代碼來源:Parser.cs

示例6: jj_3R_86

		private bool jj_3R_86()
		{
			if (jj_3R_89())
				return true;
			if (ToRefactor1())
				return false;
			while(true)
			{
				Token xsp = jj_scanpos;
				if (jj_3R_90())
				{
					jj_scanpos = xsp;
					break;
				}
				if (ToRefactor1())
					return false;
			}
			return false;
		}
開發者ID:rambo-returns,項目名稱:MonoRail,代碼行數:19,代碼來源:Parser.cs

示例7: jj_3R_19

		private bool jj_3R_19()
		{
			Token xsp;
			xsp = jj_scanpos;
			if (jj_3R_38())
			{
				jj_scanpos = xsp;
				if (jj_3R_39())
					return true;
				if (ToRefactor1())
					return false;
			}
			else if (ToRefactor1())
				return false;
			return false;
		}
開發者ID:rambo-returns,項目名稱:MonoRail,代碼行數:16,代碼來源:Parser.cs

示例8: jj_3R_38

		private bool jj_3R_38()
		{
			if (ScanToken(ParserConstants.IDENTIFIER))
				return true;
			if (ToRefactor1())
				return false;
			while(true)
			{
				Token xsp = jj_scanpos;
				if (jj_3_7())
				{
					jj_scanpos = xsp;
					break;
				}
				if (ToRefactor1())
					return false;
			}
			return false;
		}
開發者ID:rambo-returns,項目名稱:MonoRail,代碼行數:19,代碼來源:Parser.cs

示例9: jj_3_7

		private bool jj_3_7()
		{
			if (ScanToken(ParserConstants.DOT))
				return true;
			if (ToRefactor1())
				return false;
			Token xsp = jj_scanpos;
			if (jj_3R_50(jj_3R_29()))
			{
				jj_scanpos = xsp;
				if (jj_3R_50(jj_3R_41()))
					return true;
				if (ToRefactor1())
					return false;
			}
			else if (ToRefactor1())
				return false;
			return false;
		}
開發者ID:rambo-returns,項目名稱:MonoRail,代碼行數:19,代碼來源:Parser.cs

示例10: TokenLexicalActions

		private void TokenLexicalActions(Token matchedToken)
		{
			switch(jjmatchedKind)
			{
				case 5:
					if (image == null)
						image = new StringBuilder(new String(input_stream.GetSuffix(jjimageLen + (jjmatchedPos + 1))));
					else
						image.Append(input_stream.GetSuffix(jjimageLen + (jjmatchedPos + 1)));
					if (!inComment)
						lparen++;

					/*
		    * If in REFERENCE and we have seen the dot, then move 
		    * to REFMOD2 -> Modifier()
		    */

					if (curLexState == REFMODIFIER)
						SwitchTo(REFMOD2);
					break;
				case 6:
					if (image == null)
						image = new StringBuilder(new String(input_stream.GetSuffix(jjimageLen + (jjmatchedPos + 1))));
					else
						image.Append(input_stream.GetSuffix(jjimageLen + (jjmatchedPos + 1)));
					RPARENHandler();
					break;
				case 7:
					if (image == null)
						image = new StringBuilder(new String(input_stream.GetSuffix(jjimageLen + (jjmatchedPos + 1))));
					else
						image.Append(input_stream.GetSuffix(jjimageLen + (jjmatchedPos + 1)));
					/*
		    * need to simply switch back to REFERENCE, not drop down the stack
		    * because we can (infinitely) chain, ala 
		    * $foo.bar().blargh().woogie().doogie()
		    */

					SwitchTo(REFERENCE);
					break;
				case 9:
					if (image == null)
						image = new StringBuilder(new String(input_stream.GetSuffix(jjimageLen + (jjmatchedPos + 1))));
					else
						image.Append(input_stream.GetSuffix(jjimageLen + (jjmatchedPos + 1)));
					if (! inComment)
					{
						inDirective = true;

						if (debugPrint)
							Console.Out.Write("#set :  going to {0}", DIRECTIVE);

						StateStackPush();
						inSet = true;
						SwitchTo(DIRECTIVE);
					}
					break;
				case 19:
					if (image == null)
						image = new StringBuilder(new String(input_stream.GetSuffix(jjimageLen + (jjmatchedPos + 1))));
					else
						image.Append(input_stream.GetSuffix(jjimageLen + (jjmatchedPos + 1)));
					inComment = false;
					StateStackPop();
					break;
				case 20:
					if (image == null)
						image = new StringBuilder(new String(input_stream.GetSuffix(jjimageLen + (jjmatchedPos + 1))));
					else
						image.Append(input_stream.GetSuffix(jjimageLen + (jjmatchedPos + 1)));
					inComment = false;
					StateStackPop();
					break;
				case 21:
					if (image == null)
						image = new StringBuilder(new String(input_stream.GetSuffix(jjimageLen + (jjmatchedPos + 1))));
					else
						image.Append(input_stream.GetSuffix(jjimageLen + (jjmatchedPos + 1)));
					inComment = false;
					StateStackPop();
					break;
				case 24:
					if (image == null)
						image = new StringBuilder(new String(input_stream.GetSuffix(jjimageLen + (jjmatchedPos + 1))));
					else
						image.Append(input_stream.GetSuffix(jjimageLen + (jjmatchedPos + 1)));
					/*
		    *  - if we are in DIRECTIVE and haven't seen ( yet, then also drop out. 
		    *      don't forget to account for the beloved yet wierd #set
		    *  - finally, if we are in REFMOD2 (remember : $foo.bar( ) then " is ok!
		    */

					if (curLexState == DIRECTIVE && !inSet && lparen == 0)
						StateStackPop();
					break;
				case 27:
					if (image == null)
						image = new StringBuilder(new String(input_stream.GetSuffix(jjimageLen + (jjmatchedPos + 1))));
					else
						image.Append(input_stream.GetSuffix(jjimageLen + (jjmatchedPos + 1)));
//.........這裏部分代碼省略.........
開發者ID:ralescano,項目名稱:castle,代碼行數:101,代碼來源:ParserTokenManager.cs

示例11: jj_3R_90

		private bool jj_3R_90()
		{
			Token xsp = jj_scanpos;
			if (jj_3R_100(ParserConstants.LOGICAL_EQUALS, jj_3R_89()))
			{
				jj_scanpos = xsp;
				if (jj_3R_100(ParserConstants.LOGICAL_NOT_EQUALS, jj_3R_89()))
					return true;
				if (ToRefactor1())
					return false;
			}
			else if (ToRefactor1())
				return false;
			return false;
		}
開發者ID:rambo-returns,項目名稱:MonoRail,代碼行數:15,代碼來源:Parser.cs

示例12: jj_3R_57

		private bool jj_3R_57()
		{
			if (ScanToken(ParserConstants.LBRACKET))
				return true;
			if (ToRefactor1())
				return false;
			Token xsp = jj_scanpos;
			if (jj_3R_77())
				jj_scanpos = xsp;
			else if (ToRefactor1())
				return false;
			if (ScanToken(ParserConstants.RBRACKET))
				return true;
			if (ToRefactor1())
				return false;
			return false;
		}
開發者ID:rambo-returns,項目名稱:MonoRail,代碼行數:17,代碼來源:Parser.cs

示例13: jj_3R_29

		private bool jj_3R_29()
		{
			if (jj_3R_41())
				return true;
			if (ToRefactor1())
				return false;
			if (ScanToken(ParserConstants.LPAREN))
				return true;
			if (ToRefactor1())
				return false;
			Token xsp = jj_scanpos;
			if (jj_3R_42())
				jj_scanpos = xsp;
			else if (ToRefactor1())
				return false;
			if (ScanToken(ParserConstants.REFMOD2_RPAREN))
				return true;
			if (ToRefactor1())
				return false;
			return false;
		}
開發者ID:rambo-returns,項目名稱:MonoRail,代碼行數:21,代碼來源:Parser.cs

示例14: jj_3R_82

		private bool jj_3R_82()
		{
			if (jj_3R_84())
				return true;
			if (ToRefactor1())
				return false;
			while(true)
			{
				Token xsp = jj_scanpos;
				if (jj_3R_100(ParserConstants.LOGICAL_OR, jj_3R_84()))
				{
					jj_scanpos = xsp;
					break;
				}
				if (ToRefactor1())
					return false;
			}
			return false;
		}
開發者ID:rambo-returns,項目名稱:MonoRail,代碼行數:19,代碼來源:Parser.cs

示例15: jj_3_11

		private bool jj_3_11()
		{
			Token xsp = jj_scanpos;
			if (jj_3R_52())
				jj_scanpos = xsp;
			else if (ToRefactor1())
				return false;
			if (ScanToken(ParserConstants.LOGICAL_NOT))
				return true;
			if (ToRefactor1())
				return false;
			if (jj_3R_33())
				return true;
			if (ToRefactor1())
				return false;
			return false;
		}
開發者ID:rambo-returns,項目名稱:MonoRail,代碼行數:17,代碼來源:Parser.cs


注:本文中的NVelocity.Runtime.Parser.Token類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。