Re: [csswg-drafts] [mediaqueries-5] Parsing `<media-query-list>` when the input is `<whitespace-token>` (#9173)

Fwiw, I think leading and trailing whitespaces can be removed from any list of component values (prelude, declaration value, etc) in *consume a list of component values*, which is a better separation of concerns imo.

<details>

**Consume a list of component values**

  1. Discard whitespace from `input`.
  2. Process `input`:
      - `<EOF-token>` or one of the stop token (if passed): while the last item in `values` is a `<whitespace-token>`, remove that token, return `values`.
      - anything else: consume a component value from `input`, and append the result to `values`.

**Consume a declaration**

Steps 4 and 5 are replaced with:

  4. Consume a list of component values from `input`, with `<semicolon-token>` as a stop token, and `<}-token>` if `nested` is true.

**Consume a qualified rule**

  1. Consume a list of component values from `input`, with `<{-token>` as a stop token, and `<}-token>` and `<semicolor-token>` if `nested` is true. Assign the result to the rule's prelude.
  2. Process `input`:
    - `<{-token>`: [same as currently written]
    - anything else: this is a parse error, return nothing.

**Consume an at-rule**

  1. Consume a list of component values from `input`, with `<{-token>` and `<semicolon-token>` as stop tokens, and `<}-token>` if `nested` is true. Assign the result to the rule's prelude.
  2. Process `input`:
    - `<EOF-token>`, `<semicolon-token>`: [same as currently written]
    - `<{-token>`: [same as currently written]
    - `<}-token>`:
      - if `nested` is true, [same as currently written]
      - otherwise: this is a parse error, return nothing

</details>

Basically, it would be invoked with an optional list of stop tokens (without the `nested` argument):

  - `,` for a comma-separate list
  - `;` and `}` for a declaration value
  - `{`, `}`, `;` for the prelude of a nested rule
  - `{` for the prelude of a top-level qualified rule
  - `{` and `;` for the prelude of a top-level at-rule

-- 
GitHub Notification of comment by cdoublev
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/9173#issuecomment-1916887949 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 30 January 2024 13:47:03 UTC