コード例 #1
0
ファイル: StdParseHelpers.cs プロジェクト: jmclain/Nmp
		/////////////////////////////////////////////////////////////////////////////

		public static int _SkipWhiteSpace( IParseReader input )
		{
			// ******
			int count = 0;
			while( char.IsWhiteSpace(input.Peek()) ) {
				input.Skip( 1 );
				++count;
			}

			// ******
			return count;
		}
コード例 #2
0
		/////////////////////////////////////////////////////////////////////////////
		
		public string GetQuotedText( IParseReader input, bool keepQuotes )
		{
			// ******
			StringBuilder sb = new StringBuilder();
			if( keepQuotes ) {
				sb.Append( SeqOpenQuote.Sequence );
			}
		
			// ******
			while( true ) {
				char ch = input.Peek();

				if( SeqOpenQuote.FirstChar == ch && SeqOpenQuote.Starts(input) ) {
					SeqOpenQuote.Skip( input );

					// ******
					sb.Append( GetQuotedText(input, true) );
				}

				else if( SeqCloseQuote.FirstChar == ch && SeqCloseQuote.Starts(input) ) {
					SeqCloseQuote.Skip( input );

					// ******
					if( keepQuotes ) {
						sb.Append( SeqCloseQuote.Sequence );
					}
					return sb.ToString();
				}
				else if( SC.NO_CHAR == ch ) {

	// TODO: need file/line/col number for use with MPError

					ThreadContext.MacroError( "end of data: unbalanced quotes" );

				}
				else {
					input.Skip( 1 );
					sb.Append( ch );
				}
			}
		}
コード例 #3
0
ファイル: CharSequence.cs プロジェクト: jmclain/Nmp
		/////////////////////////////////////////////////////////////////////////////

		public void Skip( IParseReader input )
		{
			// ******
			if( FirstChar == input.Peek() && input.StartsWith(Sequence) ) {
				input.Skip( Sequence.Length );
			}
			else {
				throw new Exception( string.Format("input buffer does not begin with \"{1}\"", Sequence) );
			}
		}