# `StylesheetParser.Selector.Parser`
[🔗](https://github.com/zestcreative/stylesheet_parser/blob/v0.1.0/lib/stylesheet_parser/selector/parser.ex#L1)

[Selectors Level 4](https://www.w3.org/TR/selectors-4/), over component values, as
`StylesheetParser.parse_component_values/1` returns them: an attribute selector is a `[]`
`StylesheetParser.SimpleBlock`, and a functional pseudo-class or pseudo-element is a
`StylesheetParser.Function`, its arguments its component values, except for the pseudo-classes whose
arguments parse here, a `StylesheetParser.PseudoClass`: `:is()`, `:where()`, `:not()` and the
`:nth-*()` ones. `&` is the nesting selector of
[CSS Nesting](https://www.w3.org/TR/css-nesting-1/).

Each parser returns what it parsed, or nil, and the component values after it. A selector list
parses whole when nothing is after it:

    iex> {:ok, values} = StylesheetParser.parse_component_values("nav > a:hover, .button")
    iex> {selectors, []} = StylesheetParser.Selector.Parser.selector_list(values)
    iex> Enum.map(selectors, &to_string/1)
    ["nav > a:hover", ".button"]

    iex> {:ok, values} = StylesheetParser.parse_component_values("a, #1st")
    iex> {[%StylesheetParser.SimpleSelector{value: "a"}], rest} =
    ...>   StylesheetParser.Selector.Parser.selector_list(values)
    iex> rest
    [comma: ",", whitespace: " ", hash: "#1st"]

A nested rule's selectors may be relative, as `> a`:

    iex> {:ok, values} = StylesheetParser.parse_component_values("> a, + b")
    iex> {selectors, []} = StylesheetParser.Selector.Parser.relative_selector_list(values)
    iex> Enum.map(selectors, &to_string/1)
    ["> a", "+ b"]

# `an_b`

The [An+B microsyntax](https://www.w3.org/TR/css-syntax-3/#anb-microsyntax), `{a, b}`, as `2n+1`
and `odd` are `{2, 1}`. It isn't a token of its own: `2n+1` is a dimension and a number, `n-1`
an ident, `2n - 1` a dimension, a `-` and a number.

# `attr_matcher`

# `attr_modifier`

# `attribute_selector`

    <attribute-selector> = '[' <wq-name> ']' |
                  '[' <wq-name> <attr-matcher> [ <string-token> | <ident-token> ] <attr-modifier>? ']'

# `class_selector`

# `combinator`

# `complex_selector`

    <complex-selector> = <compound-selector> [ <combinator>? <compound-selector> ]*

# `compound_selector`

    <compound-selector> = [ <type-selector>? <subclass-selector>*
                            [ <pseudo-element-selector> <pseudo-class-selector>* ]* ]!

# `compound_selector_list`

    <compound-selector-list> = <compound-selector>#

# `declaration_value`

The `<declaration-value>` production matches any sequence of one or more tokens, so long as the
sequence does not contain `<bad-string-token>`, `<bad-url-token>`, unmatched `<)-token>`,
`<]-token>`, or `<}-token>`, or top-level `<semicolon-token>` tokens or `<delim-token>` tokens with
a value of `"!"`. It represents the entirety of what a valid declaration can have as its value.

# `id_selector`

# `nesting_selector`

# `ns_prefix`

# `pseudo_class_selector`

# `pseudo_element_selector`

# `relative_selector`

    <relative-selector> = <combinator>? <complex-selector>

A complex selector, its first compound selector after its combinator, as `> a` is
`%ComplexSelector{value: [[{:child_combinator, ">"}, a]]}`.

# `relative_selector_list`

    <relative-selector-list> = <relative-selector>#

# `selector_list`

    <selector-list> = <complex-selector-list>
    <complex-selector-list> = <complex-selector>#

# `simple_selector`

    <simple-selector> = <type-selector> | <subclass-selector>

# `simple_selector_list`

    <simple-selector-list> = <simple-selector>#

# `subclass_selector`

    <subclass-selector> = <id-selector> | <class-selector> |
                          <attribute-selector> | <pseudo-class-selector>

and the `&` nesting selector.

# `type_selector`

# `wq_name`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
