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


C# Token.AppendNL方法代码示例

本文整理汇总了C#中Token.AppendNL方法的典型用法代码示例。如果您正苦于以下问题:C# Token.AppendNL方法的具体用法?C# Token.AppendNL怎么用?C# Token.AppendNL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Token的用法示例。


在下文中一共展示了Token.AppendNL方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Parse

		public Token Parse( Token source )
		{
			this.Source = source.String;
			int sourceEned = this.Source.Length;
			this.Line = 1;
			this.BOL = true;
			this.EnableOutput = true;

			//Accumulate ouput into this token
			var output = new Token( Token.Kind.Text );
			int emptyLines = 0;

			//Enabel output only if all embedded #if's were true
			bool oldOutputEnabled = true;
			bool outputEnabled = true;
			int outputDisabledLine = 0;

			for ( int i = 0; i < sourceEned; i++ )
			{
				int oldLine = this.Line;
				Token t = this.GetToken( true );

				NextToken:
				switch ( t.Type )
				{
					case Token.Kind.Error:
						return t;

					case Token.Kind.EOS:
						return output; //Force termination

					case Token.Kind.Comment:
						//C comments are replaced with single spaces.
						if ( outputEnabled )
						{
							output.Append( " ", 1 );
							output.AppendNL( this.Line - oldLine );
						}
						break;

					case Token.Kind.Linecomment:
						//C++ comments are ignored
						continue;
					case Token.Kind.Directive:
						t = this.HandleDirective( t, oldLine );
						outputEnabled = this.EnableOutput;
						if ( outputEnabled != oldOutputEnabled )
						{
							if ( outputEnabled )
							{
								output.AppendNL( oldLine - outputDisabledLine );
							}
							else
							{
								outputDisabledLine = oldLine;
							}
							oldOutputEnabled = outputEnabled;
						}

						if ( outputEnabled )
						{
							output.AppendNL( this.Line - oldLine - t.CountNL );
						}
						goto NextToken;

					case Token.Kind.Linecont:
						//Backslash-Newline sequences are delted, no matter where.
						emptyLines++;
						break;

					case Token.Kind.Newline:
						if ( emptyLines > 0 )
						{
							// Compensate for the backslash-newline combinations
							// we have encountered, otherwise line numeration is broken
							if ( outputEnabled )
							{
								output.AppendNL( emptyLines );
							}
							emptyLines = 0;
						}
						goto default;
					case Token.Kind.Whitespace:
					default:
						//Passthrough all other tokens
						if ( outputEnabled )
						{
							output.Append( t );
						}
						break;
				}
			}

			if ( this.EnableOutput == false )
			{
				this.Error( this.Line, "Unclosed #if at end of source", null );
				return Token.Error;
			}

			return output;
//.........这里部分代码省略.........
开发者ID:ryan-bunker,项目名称:axiom3d,代码行数:101,代码来源:GLSLESPreprocessor.cs


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