/////////////////////////////////////////////////////////////////////////////
		
		public string GetQuotedText( IParseReader input, bool keepQuotes, bool processEscapes )
		{
			bool checkEscapesAndSpecialChars = input.CheckEscapesAndSpecialChars;
			input.CheckEscapesAndSpecialChars = processEscapes;

			string result = GetQuotedText( input, keepQuotes );

			input.CheckEscapesAndSpecialChars = checkEscapesAndSpecialChars;
			return result;
		}
Example #2
0
		/////////////////////////////////////////////////////////////////////////////

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

			// ******
			return count;
		}
		/////////////////////////////////////////////////////////////////////////////
		
		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 );
				}
			}
		}
Example #4
0
		/////////////////////////////////////////////////////////////////////////////

		public bool Starts( IParseReader input )
		{
			return input.StartsWith( Sequence );
		}
Example #5
0
		/////////////////////////////////////////////////////////////////////////////

		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) );
			}
		}
Example #6
0
		/////////////////////////////////////////////////////////////////////////////

		public bool Matches( IParseReader input, int startIndex )
		{
			return input.Matches( startIndex, Sequence );
		}
Example #7
0
		/////////////////////////////////////////////////////////////////////////////
		
		public static string _PeekToken( IParseReader input, int startIndex )
		{
			// ******
			StringBuilder sb = new StringBuilder();
		
			// ******
			for( int i = startIndex; ; i++ ) {
				char ch = input.Peek( i );

				if( char.IsLetterOrDigit(ch) || '_' == ch ) {
					sb.Append( ch );
				}
				else {
					break;
				}
			}

			// ******
			return sb.ToString();
		}
Example #8
0
		/////////////////////////////////////////////////////////////////////////////

		public static string _GetToken( IParseReader input )
		{
			// ******
			StringBuilder sb = new StringBuilder();

			// ******
			while( true ) {
				char ch = input.Peek();

				if( char.IsLetterOrDigit(ch) || '_' == ch ) {
					sb.Append( input.Next() );
				}
				else {
					return sb.ToString();
				}
			}
		}