-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.ml
96 lines (81 loc) · 2.64 KB
/
types.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
type expr =
| Ident of string
| Strlit of string
| Uri of string
| Concat of expr list
| Number of float * string option
| Function of string * expr
| Hexcolor of string
| Unary of string * expr
| Nary of string * expr list
| Key_value of string * string * expr
type declaration = string * expr * bool
type selector =
| No_element
| All_elements
| Element of string
| Id of selector * string
| Class of selector * string
| Pseudo_class of selector * string * pseudo_class_arg list option
| Pseudo_element of selector * string
| Attribute of selector * string * (string * expr) option
| Combinator of selector * string * selector
and pseudo_class_arg =
| Nested_selector of selector
| Nth of nth
and nth =
| Even | Odd
| Formula of int * int
(* a and b in an+b *)
type media_expr = string * expr option
type media_query = string option * string option * media_expr list
type descriptor_declaration = string * expr
type keyframe_ruleset = expr * declaration list
type supports_declaration = string * expr
type condition =
| Not of condition
| And of condition list
| Or of condition list
| Decl of supports_declaration
(*XXX: | Enclosed of expr*)
type statement =
| Ruleset of selector list * declaration list
(* <selectors> { <declarations> } *)
| Media of media_query list * statement list
(* @media <queries> { <rulesets> } *)
| Import of expr * media_query list
(* @import <target> [<media>]; *)
| Charset of string
(* @charset "<charset>"; *)
| Page of string option * declaration list
(* @page [<pseudo_page>] { <declarations> } *)
| Font_face of descriptor_declaration list
(* @font-face { <declarations> } *)
| Namespace of string option * expr
(* @namespace [<prefix>] "<uri>"; *)
| Keyframes of string * string * keyframe_ruleset list
(* @[-<prefix>-]keyframes <id> { <rulesets> } *)
| Supports of condition * statement list
(* @supports <condition> { <rulesets> } *)
| Viewport of string * declaration list
(* @[-<prefix>-]viewport { <declarations> } *)
type stylesheet = statement list
type box =
| Expr of expr
| Declaration of declaration
| Selector of selector
| Pseudo_class_arg of pseudo_class_arg
| Media_expr of media_expr
| Media_query of media_query
| Descriptor_declaration of descriptor_declaration
| Keyframe_ruleset of keyframe_ruleset
| Supports_declaration of supports_declaration
| Condition of condition
| Statement of statement
| Stylesheet of stylesheet
| Clear
type loc = string * int * int * int * int
exception Syntax_error of string
exception Loc_error of loc * string
exception Box_error of box * string
exception Exit_success