/// <summary> /// Called before the property name has been detected. /// </summary> public CssProperty CreateDeclarationWith(Func <String, CssProperty> createProperty, ref CssToken token) { var property = default(CssProperty); var sb = Pool.NewStringBuilder(); var start = token.Position; while (token.IsDeclarationName()) { sb.Append(token.ToValue()); token = NextToken(); } var propertyName = sb.ToPool(); if (propertyName.Length > 0) { property = _parser.Options.IsIncludingUnknownDeclarations || _parser.Options.IsToleratingInvalidValues ? new CssUnknownProperty(propertyName) : createProperty(propertyName); if (property == null) { RaiseErrorOccurred(CssParseError.UnknownDeclarationName, start); } else { _nodes.Push(property); } CollectTrivia(ref token); if (token.Type == CssTokenType.Colon) { var important = false; var value = CreateValue(CssTokenType.CurlyBracketClose, ref token, out important); if (value == null) { RaiseErrorOccurred(CssParseError.ValueMissing, token.Position); } else if (property != null && property.TrySetValue(value)) { property.IsImportant = important; } CollectTrivia(ref token); } else { RaiseErrorOccurred(CssParseError.ColonMissing, token.Position); } JumpToDeclEnd(ref token); if (property != null) { _nodes.Pop(); } } else if (token.Type != CssTokenType.EndOfFile) { RaiseErrorOccurred(CssParseError.IdentExpected, start); JumpToDeclEnd(ref token); } if (token.Type == CssTokenType.Semicolon) { token = NextToken(); } return(property); }