types.ml 2.6 KB

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