xref: /inferno-os/module/css.m (revision 46439007cf417cbd9ac8049bb4122c890097a0fa)
1#
2# CSS parsing module
3#
4# CSS2.1 style sheets
5#
6# Copyright © 2001, 2005 Vita Nuova Holdings Limited.  All rights reserved.
7#
8CSS: module
9{
10	PATH:	con "/dis/lib/w3c/css.dis";
11
12	Stylesheet: adt {
13		charset:	string;
14		imports:	list of ref Import;
15		statements:	list of ref Statement;
16	};
17
18	Import: adt {
19		name:	string;
20		media:	list of string;
21	};
22
23	Statement: adt {
24		pick{
25		Media =>
26			media:	list of string;
27			rules:	list of ref Statement.Ruleset;
28		Page =>
29			pseudo:	string;
30			decls:	list of ref Decl;
31		Ruleset =>
32			selectors:	list of Selector;
33			decls:	list of ref Decl;
34		}
35	};
36
37	Decl: adt {
38		property:	string;
39		values:	list of ref Value;
40		important:	int;
41	};
42
43	Selector:	type list of (int, Simplesel);	# int is combinator from [ >+]
44	Simplesel: type list of ref Select;
45
46	Select: adt {
47		name:	string;
48		pick{
49		Element or ID or Any or Class or Pseudo =>
50		Attrib =>
51			op:	string;	# "=" "~=" "|="
52			value:	ref Value;	# optional Ident or String
53		Pseudofn =>
54			arg:	string;
55		}
56	};
57
58	Value: adt {
59		sep:	int;	# which operator of [ ,/] preceded this value in list
60		pick{
61		String or
62		Number or
63		Percentage or
64		Url or
65		Unicoderange =>
66			value:	string;
67		Hexcolour =>
68			value:	string;	# as given
69			rgb:	(int, int, int);	# converted
70		RGB =>
71			args:	cyclic list of ref Value;	# as given
72			rgb:	(int, int, int);		# converted
73		Ident =>
74			name:	string;
75		Unit =>
76			value:	string;	# int or float
77			units:	string;	# suffix giving units ("cm", "khz", and so on, always lower case)
78		Function =>
79			name:	string;
80			args:		cyclic list of ref Value;
81		}
82	};
83
84	init:	fn(diag: int);
85	parse:	fn(s: string): (ref Stylesheet, string);
86	parsedecl:	fn(s: string): (list of ref Decl, string);
87#	unescape:	fn(s: string): string;
88};
89