private TypeSelector ParseTypeSelector() { TypeSelector selector = null; SelectorNamespacePrefix prefix = ParseNamespacePrefix(); if (CurrentToken != null && CurrentToken.TokenType == SelectorTokenType.Ident) { selector = new TypeSelector(CurrentToken.Text, prefix); currentPosition++; } return(selector); }
private TypeSelector ParseUniversalSelector() { TypeSelector selector = null; SelectorNamespacePrefix prefix = ParseNamespacePrefix(); if (CurrentToken != null && CurrentToken.Text == "*") { selector = new UniversalSelector(prefix); currentPosition++; } return(selector); }
private SelectorNamespacePrefix ParseNamespacePrefix() { SelectorNamespacePrefix prefix = null; if (CurrentToken != null) { if (CurrentToken.TokenType == SelectorTokenType.Ident) { string ident = CurrentToken.Text; currentPosition++; if (CurrentToken == null) { currentPosition--; } else if (CurrentToken.Text == "|") { prefix = new SelectorNamespacePrefix(ident); currentPosition++; } else { currentPosition--; } } else if (CurrentToken.Text == "*") { currentPosition++; if (CurrentToken == null) { currentPosition--; } else if (CurrentToken.Text == "|") { prefix = new SelectorNamespacePrefix("*"); currentPosition++; } else { currentPosition--; } } else if (CurrentToken.Text == "|") { //TODO: is this supposed to mean universal selector? prefix = new SelectorNamespacePrefix(""); currentPosition++; } } return(prefix); }
private SelectorNamespacePrefix ParseNamespacePrefix() { SelectorNamespacePrefix prefix = null; if (CurrentToken != null) { if (CurrentToken.TokenType == SelectorTokenType.Ident) { string ident = CurrentToken.Text; currentPosition++; if (CurrentToken == null) { currentPosition--; } else if (CurrentToken.Text == "|") { prefix = new SelectorNamespacePrefix(ident); currentPosition++; } else { currentPosition--; } } else if (CurrentToken.Text == "*") { currentPosition++; if (CurrentToken == null) { currentPosition--; } else if (CurrentToken.Text == "|") { prefix = new SelectorNamespacePrefix("*"); currentPosition++; } else { currentPosition--; } } else if (CurrentToken.Text == "|") { //TODO: is this supposed to mean universal selector? prefix = new SelectorNamespacePrefix(""); currentPosition++; } } return prefix; }
public TypeSelector(string name, SelectorNamespacePrefix prefix) : this(name) { this.Namespace = prefix; }
public UniversalSelector(SelectorNamespacePrefix prefix) : base("*", prefix) { }
private IFilter ParseAttributeFilter() { IFilter selector = null; if (CurrentToken.Text == "[") { currentPosition++; SkipWhiteSpace(); SelectorNamespacePrefix ns = ParseNamespacePrefix(); string attributeType = Consume(SelectorTokenType.Ident); SkipWhiteSpace(); var filterLookup = new Dictionary <SelectorToken, Func <string, IFilter> >() { { new SelectorToken(SelectorTokenType.PrefixMatch, "^="), text => new AttributePrefixFilter(attributeType, text) }, { new SelectorToken(SelectorTokenType.SuffixMatch, "$="), text => new AttributeSuffixFilter(attributeType, text) }, { new SelectorToken(SelectorTokenType.SubstringMatch, "*="), text => new AttributeSubstringFilter(attributeType, text) }, { new SelectorToken(SelectorTokenType.Text, "="), text => new AttributeExactFilter(attributeType, text) }, { new SelectorToken(SelectorTokenType.Includes, "~="), text => new AttributeIncludesFilter(attributeType, text) }, { new SelectorToken(SelectorTokenType.DashMatch, "|="), text => new AttributeDashFilter(attributeType, text) } }; if (filterLookup.ContainsKey(CurrentToken)) { SelectorToken token = CurrentToken; currentPosition++; SkipWhiteSpace(); if (CurrentToken.TokenType == SelectorTokenType.Ident) { selector = filterLookup[token](CurrentToken.Text); } else if (CurrentToken.TokenType == SelectorTokenType.String) { selector = filterLookup[token](CurrentToken.Text.Substring(1, CurrentToken.Text.Length - 2)); } else { ParseError("Unexpected token type for attribute matcher"); } currentPosition++; SkipWhiteSpace(); } else { Expect("]"); } if (CurrentToken.Text == "]" && selector == null) { selector = new AttributeFilter(attributeType); currentPosition++; } else if (CurrentToken.Text == "]" && selector != null) { currentPosition++; } else { //parse error lolz } } return(selector); }
public TypeSelector(string name, SelectorNamespacePrefix prefix) : this(name) { this.Namespace = prefix; }
public UniversalSelector(SelectorNamespacePrefix prefix) : base("*", prefix) { }