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


C# IScanner.Read方法代码示例

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


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

示例1: ParseMain

		/// <summary>
		/// Inner parse method
		/// </summary>
		/// <param name="scanner">scanner</param>
		/// <returns>the match</returns>
		protected override ParserMatch ParseMain(IScanner scanner)
		{
			long offset = scanner.Offset;
			int len = 0;

			if (scanner.Peek() == '\r')    // CR
			{
				scanner.Read();
				++len;
			}

			if (scanner.Peek() == '\n')    // LF
			{
				scanner.Read();
				++len;
			}

			if (len>0)
			{
				ParserMatch m = ParserMatch.CreateSuccessfulMatch(scanner, offset, len);
				return m;
			}
			scanner.Seek(offset);
			return ParserMatch.CreateFailureMatch(scanner);
		}
开发者ID:JohnThomson,项目名称:libpalaso,代码行数:30,代码来源:EolParser.cs

示例2: TryMatch

        public ParserMatch TryMatch(IScanner scan)
        {
            int offset = scan.Offset;
            int len = 0;

            if (!scan.EndOfInput && scan.Peek() == '\r') // CR
            {
                scan.Read();
                len++;
            }

            if (!scan.EndOfInput && scan.Peek() == '\n') // LF
            {
                scan.Read();
                len++;
            }

            if (len > 0)
            {
                return scan.CreateMatch(this, offset, len);
            }

            scan.Seek(offset);
            return scan.NoMatch;
        }
开发者ID:i-e-b,项目名称:Phantom2,代码行数:25,代码来源:EndOfLine.cs

示例3: TryMatch

        public ParserMatch TryMatch(IScanner scan)
        {
            if (scan.EndOfInput) return scan.NoMatch;

            int offset = scan.Offset;
            var m = scan.CreateMatch(this, offset, 1);
            scan.Read();
            return m;
        }
开发者ID:i-e-b,项目名称:Phantom2,代码行数:9,代码来源:AnyCharacter.cs

示例4: TryMatch

        public ParserMatch TryMatch(IScanner scan)
        {
            int offset = scan.Offset;

            if (scan.EndOfInput) return scan.NoMatch;

            char c = scan.Peek();

            if (c != test) return scan.NoMatch;

            // if we arrive at this point, we have a match
            var m = scan.CreateMatch(this, offset, 1);

            // updating offset
            scan.Read();

            // return match
            return m;
        }
开发者ID:i-e-b,项目名称:Phantom2,代码行数:19,代码来源:LiteralCharacter.cs

示例5: ParseMain

		/// <summary>
		/// Inner parse method
		/// </summary>
		/// <param name="scanner">scanner</param>
		/// <returns>the match</returns>
		protected override ParserMatch ParseMain(IScanner scanner)
		{
			long offset = scanner.Offset;
			foreach(Char c in MatchedString)
			{
				// if input consummed return null
				if (scanner.AtEnd || c != scanner.Peek()  )
				{
					ParserMatch noMatch = ParserMatch.CreateFailureMatch(scanner, offset);
					scanner.Seek(offset);
					return noMatch;
				}

				// read next characted
				scanner.Read();
			}

			// if we arrive at this point, we have a match
			ParserMatch m = ParserMatch.CreateSuccessfulMatch(scanner, offset, MatchedString.Length);

			// return match
			return m;
		}
开发者ID:JohnThomson,项目名称:libpalaso,代码行数:28,代码来源:StringParser.cs

示例6: ParseMain

		/// <summary>
		/// Inner parse method
		/// </summary>
		/// <param name="scanner">scanner</param>
		/// <returns>the match</returns>

		protected override ParserMatch ParseMain(IScanner scanner)
		{
			long offset = scanner.Offset;

			bool isAccepted = Accepts(scanner.Peek());
			if (isAccepted && Negate || !isAccepted && !Negate)
			{
				return ParserMatch.CreateFailureMatch(scanner);
			}

			// match character
			scanner.Peek();
			// if we arrive at this point, we have a match
			ParserMatch m = ParserMatch.CreateSuccessfulMatch(scanner, offset, 1);

			// updating offset
			scanner.Read();

			// return match
			return m;
		}
开发者ID:JohnThomson,项目名称:libpalaso,代码行数:27,代码来源:CharParser.cs

示例7: CountLineEnds

 int CountLineEnds(IScanner scanner)
 {
     int count = 0;
     while (!scanner.EndOfInput)
     {
         if ( ! subject.TryMatch(scanner).Success) scanner.Read();
         else count++;
     }
     return count;
 }
开发者ID:i-e-b,项目名称:Phantom2,代码行数:10,代码来源:EndOfLineTests.cs


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