xref: /inferno-os/module/xpointers.m (revision 46439007cf417cbd9ac8049bb4122c890097a0fa)
1Xpointers: module
2{
3	PATH: con "/dis/lib/w3c/xpointers.dis";
4
5	One, Ole, Oge, Omul, Odiv, Omod, Oand, Oor, Oneg,
6	Onodetype, Onametest, Ofilter, Opath: con 'A'+iota;
7
8	# axis types
9	Aancestor,
10	Aancestor_or_self,
11	Aattribute,
12	Achild,
13	Adescendant,
14	Adescendant_or_self,
15	Afollowing,
16	Afollowing_sibling,
17	Anamespace,
18	Aparent,
19	Apreceding,
20	Apreceding_sibling,
21	Aself: con iota;
22
23	Xstep: adt {
24		axis:	int;	# Aancestor, ... (above)
25		op:	int;	# Onametest or Onodetype
26		ns:	string;
27		name:	string;
28		arg:	string;	# optional parameter to processing-instruction
29		preds:	cyclic list of ref Xpath;
30
31		text:	fn(nil: self ref Xstep): string;
32		axisname:	fn(i: int): string;
33	};
34
35	Xpath: adt {
36		pick{
37		E =>
38			op: int;
39			l, r: cyclic ref Xpath;
40		Fn =>
41			ns:	string;
42			name:	string;
43			args:	cyclic list of ref Xpath;
44		Var =>
45			ns: string;
46			name: string;
47		Path =>
48			abs:	int;
49			steps:	list of ref Xstep;
50		Int =>
51			val: big;
52		Real =>
53			val: real;
54		Str =>
55			s: string;
56		}
57		text:	fn(nil: self ref Xpath): string;
58	};
59
60	init:	fn();
61	framework:	fn(s: string): (string, list of (string, string, string), string);
62
63	# predefined schemes
64	element:	fn(s: string): (string, list of int, string);
65	xmlns:	fn(s: string): (string, string, string);
66	xpointer:	fn(s: string): (ref Xpath, string);
67};
68