types.ml 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. type expr =
  2. | Ident of string
  3. | Strlit of string
  4. | Uri of string
  5. | Concat of expr list
  6. | Number of float * string option
  7. | Function of string * expr
  8. | Hexcolor of string
  9. | Unary of string * expr
  10. | Nary of string * expr list
  11. type declaration = string * expr * bool
  12. type selector =
  13. | No_element
  14. | All_elements
  15. | Element of string
  16. | Id of selector * string
  17. | Class of selector * string
  18. | Pseudo_class of selector * string * selector list option
  19. | Pseudo_element of selector * string
  20. | Attribute of selector * string * (string * expr) option
  21. | Combinator of selector * string * selector
  22. (*
  23. type selector =
  24. | Simple of string
  25. | Combinator of selector * string * selector
  26. *)
  27. type media_expr = string * expr option
  28. type media_query = string option * string option * media_expr list
  29. type descriptor_declaration = string * expr
  30. type keyframe_ruleset = expr * declaration list
  31. type supports_declaration = string * expr
  32. type condition =
  33. | Not of condition
  34. | And of condition list
  35. | Or of condition list
  36. | Decl of supports_declaration
  37. (*XXX: | Enclosed of expr*)
  38. type statement =
  39. | Ruleset of selector list * declaration list
  40. (* <selectors> { <declarations> } *)
  41. | Media of media_query list * statement list
  42. (* @media <queries> { <rulesets> } *)
  43. | Import of expr * media_query list
  44. (* @import <target> [<media>]; *)
  45. | Charset of string
  46. (* @charset "<charset>"; *)
  47. | Page of string option * declaration list
  48. (* @page [<pseudo_page>] { <declarations> } *)
  49. | Font_face of descriptor_declaration list
  50. (* @font-face { <declarations> } *)
  51. | Namespace of string option * expr
  52. (* @namespace [<prefix>] "<uri>"; *)
  53. | Keyframes of string * string * keyframe_ruleset list
  54. (* @[-<prefix>-]keyframes <id> { <rulesets> } *)
  55. | Supports of condition * statement list
  56. (* @supports <condition> { <rulesets> } *)
  57. type stylesheet = statement list
  58. type box =
  59. | Expr of expr
  60. | Declaration of declaration
  61. | Selector of selector
  62. | Media_expr of media_expr
  63. | Media_query of media_query
  64. | Descriptor_declaration of descriptor_declaration
  65. | Keyframe_ruleset of keyframe_ruleset
  66. | Supports_declaration of supports_declaration
  67. | Condition of condition
  68. | Statement of statement
  69. | Stylesheet of stylesheet
  70. | Clear
  71. type loc = string * int * int * int * int
  72. exception Syntax_error of string
  73. exception Loc_error of loc * string
  74. exception Box_error of box * string
  75. exception Exit_success