Beispiel #1
0
 public Token Read()
 {
     var temp = current;
     current = next;
     next = ReadFromStream();
     return temp;
 }
Beispiel #2
0
 private Token ReadFromStream()
 {
     var token = new Token();
     var charAsInt = textReader.Read();
     if (charAsInt == -1)
     {
         token.IsEnd = true;
     }
     else
     {
         var character = (char) charAsInt;
         if (character == '\\')
         {
             charAsInt = textReader.Read();
             if (charAsInt == -1)
             {
                 throw new Exception("Last character cannot be an escape character '\\'.");
             }
             token.IsEscaped = true;
             character = (char) charAsInt;
         }
         token.Character = character;
     }
     return token;
 }
Beispiel #3
0
 public TokenReader(TextReader textReader)
 {
     this.textReader = textReader;
     current = ReadFromStream();
     if (!current.IsEnd)
     {
         next = ReadFromStream();
     }
 }
Beispiel #4
0
 private void AddCurrentValue(Token token)
 {
     if (token.IsEscaped)
     {
         currentValue += @"\";
     }
     currentValue += token.Character;
 }