···11+(*---------------------------------------------------------------------------
22+ Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved.
33+ SPDX-License-Identifier: MIT
44+ ---------------------------------------------------------------------------*)
55+66+(** CSS selector parse error codes.
77+88+ These represent all possible errors that can occur when parsing
99+ CSS selectors.
1010+*)
1111+1212+type t =
1313+ | Empty_selector
1414+ (** The selector string was empty or contained only whitespace. *)
1515+ | Unterminated_string
1616+ (** A quoted string was not closed before end of input. *)
1717+ | Unterminated_escape
1818+ (** An escape sequence was not completed before end of input. *)
1919+ | Expected_identifier_after_hash
2020+ (** Expected an identifier after [#] for ID selector. *)
2121+ | Expected_identifier_after_dot
2222+ (** Expected an identifier after [.] for class selector. *)
2323+ | Expected_attribute_name
2424+ (** Expected an attribute name inside an attribute selector. *)
2525+ | Expected_closing_bracket
2626+ (** Expected [\]] to close an attribute selector. *)
2727+ | Expected_equals_after_operator of char
2828+ (** Expected [=] after an attribute operator like [~], [|], [^], [$], or [*]. *)
2929+ | Unexpected_character_in_attribute_selector
3030+ (** Found an unexpected character inside an attribute selector. *)
3131+ | Expected_pseudo_class_name
3232+ (** Expected a pseudo-class name after [:]. *)
3333+ | Expected_closing_paren
3434+ (** Expected [)] to close a pseudo-class argument. *)
3535+ | Unexpected_character of char
3636+ (** Found an unexpected character in the selector. *)
3737+ | Expected_attribute_value
3838+ (** Expected a value after the attribute operator. *)
3939+ | Expected_closing_bracket_or_operator
4040+ (** Expected [\]] or an attribute operator like [=]. *)
4141+ | Expected_selector_after_combinator
4242+ (** Expected a selector after a combinator ([>], [+], [~], or space). *)
4343+ | Unexpected_token
4444+ (** Found an unexpected token in the selector. *)
4545+ | Expected_end_of_selector
4646+ (** Expected end of selector but found more tokens. *)
4747+4848+val to_string : t -> string
4949+(** Convert to a kebab-case string identifier suitable for programmatic use.
5050+5151+ Examples:
5252+ - [to_string Empty_selector] returns ["empty-selector"]
5353+ - [to_string (Unexpected_character 'x')] returns ["unexpected-character-x"]
5454+*)
5555+5656+val to_human_string : t -> string
5757+(** Convert to a human-readable error message.
5858+5959+ Examples:
6060+ - [to_human_string Empty_selector] returns ["Empty selector"]
6161+ - [to_human_string Expected_closing_bracket] returns ["Expected \]"]
6262+*)