xref: /inferno-os/module/xml.m (revision 7ef44d652ae9e5e1f5b3465d73684e4a54de73c0)
1Xml: module {
2	PATH: con "/dis/lib/xml.dis";
3	Item: adt {
4		fileoffset:	int;
5		pick {
6		Tag =>
7			name:	string;
8			attrs:		Attributes;
9		Text =>
10			ch:		string;
11			ws1, ws2: int;
12		Process =>
13			target:	string;
14			data:		string;
15		Doctype =>
16			name:	string;
17			public:	int;
18			params:	list of string;
19		Stylesheet =>
20			attrs:		Attributes;
21		Error =>
22			loc:		Locator;
23			msg:		string;
24		}
25	};
26
27	Locator: adt {
28		line:				int;
29		systemid:			string;
30		publicid:			string;
31	};
32
33	Attribute: adt {
34		name:			string;
35		value:			string;
36	};
37
38	Attributes: adt {
39		attrs:			list of Attribute;
40
41		all:			fn(a: self Attributes): list of Attribute;
42		get:			fn(a: self Attributes, name: string): string;
43	};
44
45	Mark: adt {
46		estack:	list of string;
47		line:		int;
48		offset:	int;
49		readdepth:	int;
50
51		str:		fn(m: self ref Mark): string;
52	};
53
54	Parser: adt {
55		in:		ref Bufio->Iobuf;
56		eof:		int;
57		lastnl:	int;
58		estack:	list of string;
59		loc:		Locator;
60		warning:	chan of (Locator, string);
61		errormsg:	string;
62		actdepth:	int;
63		readdepth:	int;
64		fileoffset:	int;
65		preelem:	string;
66		ispre:	int;
67
68		next:		fn(p: self ref Parser): ref Item;
69		up:		fn(p: self ref Parser);
70		down:	fn(p: self ref Parser);
71		mark:	fn(p: self ref Parser): ref Mark;
72		atmark:	fn(p: self ref Parser, m: ref Mark): int;
73		goto:	fn(p: self ref Parser, m: ref Mark);
74		str2mark:	fn(p: self ref Parser, s: string): ref Mark;
75	};
76	init:	fn(): string;
77	open: fn(f: string, warning: chan of (Locator, string), preelem: string): (ref Parser, string);
78	fopen:	fn(f: ref Bufio->Iobuf, srcname: string, warning: chan of (Locator, string), preelem: string): (ref Parser, string);
79};
80