(.using [library [lux (.except Label or and for same? not) ["[0]" locale (.only Locale)] [data ["[0]" text (.only) ["%" format (.only format)]]] [math [number ["i" int]]] [type [primitive (.except)]] [macro ["[0]" template]]]] ["[0]" // ["[1][0]" id (.only ID)] ["[1][0]" class (.only Class)]]) (type: .public Label Text) (type: .public Tag Label) (type: .public Attribute Label) (primitive: .public (Generic brand) Any) (template [ ] [(primitive: Any) (type: .public (Generic ))] [Can_Chain Can_Chain'] [Cannot_Chain Cannot_Chain'] ) (primitive: .public Unique Any) (primitive: .public Specific Any) (primitive: .public Composite Any) (primitive: .public (Selector kind) Text (def: .public selector (-> (Selector Any) Text) (|>> representation)) (def: .public any (Selector Cannot_Chain) (abstraction "*")) (def: .public tag (-> Tag (Selector Cannot_Chain)) (|>> abstraction)) (template [ ] [(def: .public (-> (Selector )) (|>> (format ) abstraction))] [id ID "#" Unique //id.id] [class Class "." Can_Chain //class.class] ) (template [ +] [(`` (template [ ] [(def: .public ( right left) (-> (Selector ) (Selector ) (Selector Composite)) (abstraction (format (representation left) (representation right))))] (~~ (template.spliced +))))] [Can_Chain (Generic Any) [["" and]]] [Specific (Generic Any) [["" at]]] [Unique (Generic Any) [["" for]]] [Any Any [["," or] [" " in] [">" sub] ["+" next] ["~" later]]] ) (type: .public (Specializer kind) (-> (Selector kind) (Selector (Generic Any)) (Selector Composite))) (type: .public Combinator (-> (Selector Any) (Selector Any) (Selector Composite))) (def: .public (with? attribute) (-> Attribute (Selector Can_Chain)) (abstraction (format "[" attribute "]"))) (template [ ] [(def: .public ( attribute value) (-> Attribute Text (Selector Can_Chain)) (abstraction (format "[" attribute value "]")))] ["=" same?] ["~=" has?] ["|=" has_start?] ["^=" starts?] ["$=" ends?] ["*=" contains?] ) (template [ +] [(`` (template [ ] [(def: .public (Selector ) (abstraction ))] (~~ (template.spliced +))))] [Can_Chain [[active ":active"] [checked ":checked"] [default ":default"] [disabled ":disabled"] [empty ":empty"] [enabled ":enabled"] [first_child ":first-child"] [first_of_type ":first-of-type"] [focused ":focus"] [hovered ":hover"] [in_range ":in-range"] [indeterminate ":indeterminate"] [invalid ":invalid"] [last_child ":last-child"] [last_of_type ":last-of-type"] [link ":link"] [only_of_type ":only-of-type"] [only_child ":only-child"] [optional ":optional"] [out_of_range ":out-of-range"] [read_only ":read-only"] [read_write ":read-write"] [required ":required"] [root ":root"] [target ":target"] [valid ":valid"] [visited ":visited"]]] [Specific [[after "::after"] [before "::before"] [first_letter "::first-letter"] [first_line "::first-line"] [placeholder "::placeholder"] [selection "::selection"]]] ) (def: .public (language locale) (-> Locale (Selector Can_Chain)) (|> locale locale.code (text.enclosed ["(" ")"]) (format ":lang") abstraction)) (def: .public not (-> (Selector Any) (Selector Can_Chain)) (|>> representation (text.enclosed ["(" ")"]) (format ":not") abstraction)) (primitive: .public Index Text (def: .public index (-> Nat Index) (|>> %.nat abstraction)) (template [ ] [(def: .public Index (abstraction ))] [odd "odd"] [even "even"] ) (type: .public Formula (Record [#constant Int #variable Int])) (def: .public (formula input) (-> Formula Index) (let [(open "_[0]") input] (abstraction (format (if (i.< +0 _#variable) (%.int _#variable) (%.nat (.nat _#variable))) (%.int _#constant))))) (template [ ] [(def: .public ( index) (-> Index (Selector Can_Chain)) (|> (representation index) (text.enclosed ["(" ")"]) (format ) (abstraction Selector)))] [nth_child ":nth-child"] [nth_last_child ":nth-last-child"] [nth_of_type ":nth-of-type"] [nth_last_of_type ":nth-last-of-type"] ) ) )