types.ml 1.73 KB
Newer Older
1
type expr =
2 3 4
  | Ident of string
  | Strlit of string
  | Uri of string
5 6 7
  | Concat of expr list
  | Number of float * string option
  | Function of string * expr
8
  | Hexcolor of string
9 10
  | Unary of string * expr
  | Nary of string * expr list
11

12
type declaration = string * expr * bool
13

14 15 16
type selector =
  | Simple of string
  | Combinator of selector * string * selector
17

18 19 20
type media_expr = string * expr option
type media_query = string option * string option * media_expr list

21 22 23 24
type descriptor_declaration = string * expr

type keyframe_ruleset = expr * declaration list

25 26
type supports_declaration = string * expr

27 28 29 30
type condition =
  | Not of condition
  | And of condition list
  | Or of condition list
31
  | Decl of supports_declaration
32 33
  (*XXX: | Enclosed of expr*)

34 35 36
type statement =
  | Ruleset of selector list * declaration list
  (* <selectors> { <declarations> } *)
37
  | Media of media_query list * statement list
38
  (* @media <queries> { <rulesets> } *)
39
  | Import of expr * media_query list
40
  (* @import <target> [<media>]; *)
41 42 43 44
  | Charset of string
  (* @charset "<charset>"; *)
  | Page of string option * declaration list
  (* @page [<pseudo_page>] { <declarations> } *)
45
  | Font_face of descriptor_declaration list
46
  (* @font-face { <declarations> } *)
47
  | Namespace of string option * expr
48
  (* @namespace [<prefix>] "<uri>"; *)
49
  | Keyframes of string * keyframe_ruleset list
50 51 52
  (* @keyframes <id> { <rulesets> } *)
  | Supports of condition * statement list
  (* @supports <condition> { <rulesets> } *)
53

54 55
type stylesheet = statement list

56 57 58 59 60 61 62 63
type args = {
  mutable infiles : string list;
  mutable outfile : string option;
  mutable verbose : int;
}

type loc = string * int * int * int * int

64 65
exception SyntaxError of string

66
exception LocError of loc * string