public override CssRule Create(CssToken current) { if (_parser.Options.IsIncludingUnknownRules) { var unknown = new CssUnknownRule(current.Data, _parser); _tokenizer.State = CssParseMode.Text; unknown.Prelude = _tokenizer.Get().Data; _tokenizer.State = CssParseMode.Data; if (_tokenizer.Get().Type == CssTokenType.CurlyBracketOpen) FillRules(unknown); return unknown; } else { RaiseErrorOccurred(CssParseError.UnknownAtRule, current); _tokenizer.SkipUnknownRule(); return null; } }
public CssRule CreateUnknown(CssToken current) { if (_parser.Options.IsIncludingUnknownRules) { var unknown = new CssUnknownRule(current.Data, _parser); _tokenizer.State = CssParseMode.Text; unknown.Prelude = _tokenizer.Get().Data; _tokenizer.State = CssParseMode.Selector; var sb = Pool.NewStringBuilder(); var token = _tokenizer.Get(); sb.Append(token.ToValue()); if (token.Type == CssTokenType.CurlyBracketOpen) { var curly = 1; do { token = _tokenizer.Get(); sb.Append(token.ToValue()); switch (token.Type) { case CssTokenType.CurlyBracketOpen: curly++; break; case CssTokenType.CurlyBracketClose: curly--; break; case CssTokenType.Eof: curly = 0; break; } } while (curly != 0); } unknown.Content = sb.ToPool(); _tokenizer.State = CssParseMode.Data; return unknown; } else { RaiseErrorOccurred(CssParseError.UnknownAtRule, current); _tokenizer.SkipUnknownRule(); return null; } }
public CssRule CreateUnknown(CssToken current) { var start = current.Position; if (_parser.Options.IsIncludingUnknownRules) { var token = NextToken(); var rule = new CssUnknownRule(current.Data, _parser); _nodes.Push(rule); while (token.IsNot(CssTokenType.CurlyBracketOpen, CssTokenType.Semicolon, CssTokenType.EndOfFile)) { token = NextToken(); } if (token.Type == CssTokenType.CurlyBracketOpen) { var curly = 1; do { token = NextToken(); switch (token.Type) { case CssTokenType.CurlyBracketOpen: curly++; break; case CssTokenType.CurlyBracketClose: curly--; break; case CssTokenType.EndOfFile: curly = 0; break; } } while (curly != 0); } rule.SourceCode = CreateView(start, token.Position); _nodes.Pop(); return rule; } else { RaiseErrorOccurred(CssParseError.UnknownAtRule, start); JumpToRuleEnd(ref current); return default(CssUnknownRule); } }