Exemplo n.º 1
0
        /// <summary>
        /// Reads the next character off of the input stream and advances the current position.
        /// </summary>
        /// <returns></returns>
        public SourceChar Read()
        {
            var sourceChar = this.Peek();

            switch (sourceChar.Value)
            {
            case '\r':
                this.LineNumber  += 1;
                this.ColumnNumber = 1;
                break;

            case '\n':
                var lastChar = this.LastChar;
                if ((lastChar != null) && (lastChar.Value == '\r'))
                {
                    sourceChar = new SourceChar(sourceChar.Value, this.Position, lastChar.LineNumber, lastChar.ColumnNumber + 1);
                }
                else
                {
                    this.LineNumber  += 1;
                    this.ColumnNumber = 1;
                }
                break;

            default:
                this.ColumnNumber += 1;
                break;
            }
            this.Position += 1;
            this.LastChar  = sourceChar;
            return(sourceChar);
        }
 internal UnexpectedCharacterException(SourceChar foundChar)
 {
     if (foundChar == null)
     {
         throw new ArgumentNullException("foundChar");
     }
     this.FoundChar = foundChar;
 }
Exemplo n.º 3
0
 /// <summary>
 /// BUGBUG - doesn't handle escapedUCSchar
 /// </summary>
 public void ConsumeChar(SourceChar @char)
 {
     if (this.IsEscaped)
     {
         if (_escapeMap.ContainsKey(@char.Value))
         {
             this.OutputString.Append(_escapeMap[@char.Value]);
             this.IsEscaped = false;
         }
         else
         {
             throw new UnexpectedCharacterException(@char);
         }
     }
     else if (@char.Value == StringValidator.Backslash)
     {
         this.IsEscaped = true;
     }
     else
     {
         this.OutputString.Append(@char.Value);
     }
 }
Exemplo n.º 4
0
 internal SourceExtent WithEndExtent(SourceChar sourceChar)
 {
     return(new SourceExtent(this.StartPosition, this.StartLineNumber, this.StartColumnNumber, sourceChar.Position, sourceChar.LineNumber, sourceChar.ColumnNumber, this.Text));
 }
Exemplo n.º 5
0
 internal SourceExtent WithStartExtent(SourceChar sourceChar)
 {
     return(new SourceExtent(sourceChar.Position, sourceChar.LineNumber, sourceChar.ColumnNumber, this.EndPosition, this.EndLineNumber, this.EndColumnNumber, this.Text));
 }