types.ml 2.5 KB

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