static TypeSelector Consume_Type_Selector(DataConsumer <CssToken> Stream) { if (Starts_NamespacePrefix(Stream.Next, Stream.NextNext)) { NamespacePrefixToken Namespace = Consume_NamespacePrefix(Stream); return(new TypeSelector(Namespace, Stream.Consume <IdentToken>().Value)); } return(new TypeSelector(Stream.Consume <IdentToken>().Value)); }
public AttributeSelector(NamespacePrefixToken Namespace, string Attrib, CssToken OperatorToken, string Value) : base(ESimpleSelectorType.AttributeSelector) { this.Namespace = Namespace; this.AttributeName = Attrib; if (Value == null) { Value = string.Empty; } this.Value = Value; if (OperatorToken == null || OperatorToken.Type == ECssTokenType.Delim && (OperatorToken as DelimToken).Value == '>') { this.Operator = ECssAttributeOperator.Isset; } else { switch (OperatorToken.Type) { case ECssTokenType.Delim: { if ((OperatorToken as DelimToken).Value == '=') { this.Operator = ECssAttributeOperator.Equals; } } break; case ECssTokenType.Dash_Match: this.Operator = ECssAttributeOperator.PrefixedWith; break; case ECssTokenType.Include_Match: this.Operator = ECssAttributeOperator.Includes; break; case ECssTokenType.Prefix_Match: this.Operator = ECssAttributeOperator.StartsWith; break; case ECssTokenType.Suffix_Match: this.Operator = ECssAttributeOperator.EndsWith; break; case ECssTokenType.Substring_Match: this.Operator = ECssAttributeOperator.Contains; break; default: throw new CssSelectorException("Attribute selector: operator token-to-enum translation not implemented for (", OperatorToken, ")!"); } } }
static AttributeSelector Consume_Attribute_Selector(DataConsumer <CssToken> Stream) { Stream.Consume();// Consume the '[' prefix NamespacePrefixToken NS = null; if (Starts_NamespacePrefix(Stream.Next, Stream.NextNext)) { NS = Consume_NamespacePrefix(Stream); } //QualifiedNameToken attrName = Stream.Consume<QualifiedNameToken>(); IdentToken attrName = Stream.Consume <IdentToken>(); CssToken Tok = Stream.Consume(); if (Tok.Type == ECssTokenType.SqBracket_Close) { return(new AttributeSelector(NS, attrName.Value)); } CssToken OperatorToken = Tok; CssToken value = Stream.Consume(); if (value.Type == ECssTokenType.SqBracket_Close) { return(null); // Parse error } if (Stream.Next.Type != ECssTokenType.SqBracket_Close) { return(null); // Parse error } Stream.Consume(); // Consume the closing bracket if (value.Type == ECssTokenType.String) { return(new AttributeSelector(NS, attrName.Value, OperatorToken, (value as StringToken).Value)); } else if (value.Type == ECssTokenType.Ident) { return(new AttributeSelector(NS, attrName.Value, OperatorToken, (value as IdentToken).Value)); } return(null);// Parse error }
static QualifiedNameToken Consume_QualifiedName(DataConsumer <CssToken> Stream) { NamespacePrefixToken NS = null; if (Starts_NamespacePrefix(Stream.Next, Stream.NextNext)) { NS = Consume_NamespacePrefix(Stream); } CssToken Tok = Stream.Consume(); if (Tok.Type != ECssTokenType.Ident) { return(null); } string Name = (Tok as IdentToken).Value; return(new QualifiedNameToken(Name, NS)); }
public TypeSelector(NamespacePrefixToken Namespace, string TypeName) : base(ESimpleSelectorType.TypeSelector) { this.Namespace = Namespace?.Value; this.TypeName = TypeName; }
public QualifiedNameToken(string Value, NamespacePrefixToken Namespace) : base(ECssTokenType.QualifiedName) { this.Value = Value; this.Namespace = Namespace; }
/// <summary> /// </summary> /// <param name="Attrib">The attribute name for this selector</param> /// <param name="Operator">String token that defines the method of comparison</param> /// <param name="Value"></param> public AttributeSelector(NamespacePrefixToken Namespace, string Attrib) : base(ESimpleSelectorType.AttributeSelector) { this.Namespace = Namespace; this.AttributeName = Attrib; this.Operator = ECssAttributeOperator.Isset; }