Example #1
0
        internal async Task <Stylesheet> ParseAsync(Stylesheet sheet, TextSource source)
        {
            await source.PrefetchAllAsync(CancellationToken.None).ConfigureAwait(false);

            var tokenizer = new Lexer(source);
            var start     = tokenizer.GetCurrentPosition();
            var builder   = new StylesheetComposer(tokenizer, this);
            var tasks     = new List <Task>();
            var end       = builder.CreateRules(sheet);
            var range     = new TextRange(start, end);

            sheet.StylesheetText = new StylesheetText(range, source);

            foreach (var rule in sheet.Rules)
            {
                if (rule.Type == RuleType.Charset)
                {
                    continue;
                }
                if (rule.Type != RuleType.Import)
                {
                    break;
                }
            }

            await TaskEx.WhenAll(tasks).ConfigureAwait(false);

            return(sheet);
        }
Example #2
0
        internal Stylesheet Parse(TextSource source)
        {
            var sheet     = new Stylesheet(this);
            var tokenizer = new Lexer(source);
            var start     = tokenizer.GetCurrentPosition();
            var builder   = new StylesheetComposer(tokenizer, this);
            var end       = builder.CreateRules(sheet);
            var range     = new TextRange(start, end);

            sheet.StylesheetText = new StylesheetText(range, source);
            return(sheet);
        }