-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathast.ts
64 lines (64 loc) · 1.49 KB
/
ast.ts
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
export type Urichk = Rule[];
export interface Token<TText = string> {
text: TText;
offset: number;
lineBreaks: number;
line: number;
col: number;
}
export interface Rule {
comment?: Token;
head: Head;
tail: Tail;
}
export interface Head {
scheme?: Scheme;
authority?: Authority;
path?: Path;
}
export interface Scheme extends Token {}
export interface Authority {
userinfo?: Userinfo;
host: Host;
port?: Port;
}
export interface Userinfo extends Token {}
export interface Host extends Token {}
export interface Port extends Token {}
export type Path = PathFragment[];
export type PathFragment = StaticPathFragment | ParamPathFragment;
export interface StaticPathFragment {
type: "static";
name: Token;
}
export interface ParamPathFragment {
type: "param";
name: Token;
}
export type Tail = TailRule[];
export type TailRule = TailRuleMatch | TailRuleForm;
export interface TailRuleBase<TMatch extends Token> {
comment?: Token;
tailType: Token<"?" | "#">;
matchType: TMatch;
}
export interface TailRuleMatch extends TailRuleBase<Token<"match">> {
pattern: TailRulePatternValue[];
}
export interface TailRuleForm extends TailRuleBase<Token<"form">> {
pattern: TailRuleFormPatternRule[];
}
export interface Key {
type: "id" | "string";
value: Token;
}
export interface TailRuleFormPatternRule {
comment?: Token;
key: Key;
value: TailRulePatternValue[] | null;
array: boolean;
}
export interface TailRulePatternValue {
type: "id" | "string" | "regex";
value: Token;
}