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


C# Lexer.Scan方法代码示例

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


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

示例1: Dump

 public static string Dump(Lexer aLexer)
 {
     using (var xOut = new StringWriter())
     {
         while (true)
         {
             var xToken = aLexer.Scan();
             xOut.Write(xToken.TagValue);
             var xWord = xToken as Word;
             if (xWord != null)
             {
                 xOut.Write("\t");
                 xOut.Write(xWord.Value);
             }
             var xUnknown = xToken as CharToken;
             if (xUnknown != null)
             {
                 xOut.Write("\t");
                 xOut.Write(xUnknown.Value);
             }
             xOut.WriteLine();
             if (xToken.TagValue == Tag.EndOfStream)
             {
                 break;
             }
         }
         return xOut.ToString();
     }
 }
开发者ID:Sullux,项目名称:tws,代码行数:29,代码来源:LexDumper.cs

示例2: Parse

 public static Tree Parse(Stream stream)
 {
     var lexer = new Lexer();
     var parser = new Parser();
     using (stream)
     {
         var tokens = lexer.Scan(stream);
         var tree = parser.Parse(tokens);
         return tree;
     }
 }
开发者ID:modulexcite,项目名称:graveyard,代码行数:11,代码来源:Parser.cs

示例3: TryParse

		public static bool TryParse (string input, out ProductHeaderValue parsedValue)
		{
			parsedValue = null;

			var lexer = new Lexer (input);
			var t = lexer.Scan ();
			if (t != Token.Type.Token)
				return false;

			var value = new ProductHeaderValue ();
			value.Name = lexer.GetStringValue (t);

			t = lexer.Scan ();
			if (t == Token.Type.SeparatorSlash) {
				t = lexer.Scan ();
				if (t != Token.Type.Token)
					return false;

				value.Version = lexer.GetStringValue (t);
				t = lexer.Scan ();
			}

			if (t != Token.Type.End)
				return false;

			parsedValue = value;
			return true;
		}
开发者ID:GirlD,项目名称:mono,代码行数:28,代码来源:ProductHeaderValue.cs

示例4: TryParse

		public static bool TryParse (string input, out ViaHeaderValue parsedValue)
		{
			parsedValue = null;

			var lexer = new Lexer (input);

			var t = lexer.Scan ();
			if (t != Token.Type.Token)
				return false;

			var next = lexer.Scan ();
			ViaHeaderValue value = new ViaHeaderValue ();

			if (next == Token.Type.SeparatorSlash) {
				next = lexer.Scan ();
				if (next != Token.Type.Token)
					return false;

				value.ProtocolName = lexer.GetStringValue (t);
				value.ProtocolVersion = lexer.GetStringValue (next);

				next = lexer.Scan ();
			} else {
				value.ProtocolVersion = lexer.GetStringValue (t);
			}

			if (next != Token.Type.Token)
				return false;

			if (lexer.PeekChar () == ':') {
				lexer.EatChar ();

				t = lexer.Scan ();
				if (t != Token.Type.Token)
					return false;
			} else {
				t = next;
			}

			value.ReceivedBy = lexer.GetStringValue (next, t);

			string comment;
			if (!lexer.ScanCommentOptional (out comment))
				return false;

			value.Comment = comment;
			parsedValue = value;
			return true;
		}
开发者ID:carrie901,项目名称:mono,代码行数:49,代码来源:ViaHeaderValue.cs

示例5: TryParse

		public static bool TryParse (string input, out AuthenticationHeaderValue parsedValue)
		{
			var lexer = new Lexer (input);
			var t = lexer.Scan ();
			if (t != Token.Type.Token || !(lexer.PeekChar () == ' ' || lexer.PeekChar () == -1)) {
				parsedValue = null;
				return false;
			}

			parsedValue = new AuthenticationHeaderValue ();
			parsedValue.Scheme = lexer.GetStringValue (t);

			t = lexer.Scan ();
			if (t != Token.Type.End)
				parsedValue.Parameter = lexer.GetRemainingStringValue (t.StartPosition);

			return true;
		}
开发者ID:carrie901,项目名称:mono,代码行数:18,代码来源:AuthenticationHeaderValue.cs

示例6: TryParse

		public static bool TryParse (string input, out EntityTagHeaderValue parsedValue)
		{
			parsedValue = null;

			var lexer = new Lexer (input);
			var t = lexer.Scan ();
			bool is_weak = false;

			if (t == Token.Type.Token) {
				if (lexer.GetStringValue (t) != "W" || lexer.PeekChar () != '/')
					return false;

				is_weak = true;
				lexer.EatChar ();
				t = lexer.Scan ();
			}

			if (t != Token.Type.QuotedString)
				return false;

			if (lexer.Scan () != Token.Type.End)
				return false;

			parsedValue = new EntityTagHeaderValue ();
			parsedValue.Tag = lexer.GetStringValue (t);
			parsedValue.IsWeak = is_weak;
			return true;
		}
开发者ID:carrie901,项目名称:mono,代码行数:28,代码来源:EntityTagHeaderValue.cs


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