2 using System.Collections.Generic;
5 namespace Tizen.NUI.StyleSheets
7 internal sealed class CssReader : TextReader
9 readonly TextReader _reader;
11 public CssReader(TextReader reader)
14 throw new ArgumentNullException(nameof(reader));
19 readonly Queue<char> _cache = new Queue<char>();
22 //TODO unescape escaped sequences
23 public override int Peek()
28 int p = _reader.Peek();
31 if (unchecked((char)p) != '/')
34 _cache.Enqueue(unchecked((char)_reader.Read()));
38 if (unchecked((char)p) != '*')
42 _reader.Read(); //consume the '*'
47 var next = _reader.Read();
50 if (unchecked((char)next) == '*')
52 else if (hasStar && unchecked((char)next) == '/')
53 return Peek(); //recursively call self for comments following comments
60 //TODO unescape escaped sequences
61 public override int Read()
64 return _cache.Dequeue();
66 int p = _reader.Read();
69 var c = unchecked((char)p);
76 return _cache.Dequeue();
77 c = unchecked((char)p);
79 return _cache.Dequeue();
82 _reader.Read(); //consume the '*'
87 var next = _reader.Read();
90 if (unchecked((char)next) == '*')
92 else if (hasStar && unchecked((char)next) == '/')
93 return Read(); //recursively call self for comments following comments