-
-
Notifications
You must be signed in to change notification settings - Fork 342
/
nodes.ts
138 lines (124 loc) · 2.32 KB
/
nodes.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import { SourceLocation } from './location'
export const enum NodeTypes {
Resource, // 0
Plural,
Message,
Text,
Named,
List, // 5
Linked,
LinkedKey,
LinkedModifier,
Literal
}
// not containing whitespace or control characters
export type Identifier = string
export interface Node {
type: NodeTypes
/**
* @internal `type` alias
*/
t?: NodeTypes
start?: number
end?: number
loc?: SourceLocation
}
export interface ResourceNode extends Node {
type: NodeTypes.Resource
body: MessageNode | PluralNode
/**
* @internal `body` alias
*/
b?: MessageNode | PluralNode
cacheKey?: string
helpers?: string[]
}
export interface PluralNode extends Node {
type: NodeTypes.Plural
cases: MessageNode[]
/**
* @internal `cases` alias
*/
c?: MessageNode[]
}
export interface MessageNode extends Node {
type: NodeTypes.Message
static?: string
/**
* @internal `static` alias
*/
s?: string
items: MessageElementNode[]
/**
* @internal `items` alias
*/
i?: MessageElementNode[]
}
type MessageElementNode =
| TextNode
| NamedNode
| ListNode
| LiteralNode
| LinkedNode
export interface TextNode extends Node {
type: NodeTypes.Text
value?: string
/**
* @internal `value` alias
*/
v?: string
}
export interface NamedNode extends Node {
type: NodeTypes.Named
key: Identifier
modulo?: boolean
/**
* @internal `key` alias
*/
k?: Identifier
}
export interface ListNode extends Node {
type: NodeTypes.List
index: number
/**
* @internal `index` alias
*/
i?: number
}
export interface LiteralNode extends Node {
type: NodeTypes.Literal
value?: string
/**
* @internal `value` alias
*/
v?: string
}
export interface LinkedNode extends Node {
type: NodeTypes.Linked
modifier?: LinkedModifierNode
/**
* @internal `modifier` alias
*/
m?: LinkedModifierNode
key: LinkedKeyNode | NamedNode | ListNode | LiteralNode
/**
* @internal `key` alias
*/
k?: LinkedKeyNode | NamedNode | ListNode | LiteralNode
}
export interface LinkedKeyNode extends Node {
type: NodeTypes.LinkedKey
value: string
/**
* @internal `value` alias
*/
v?: string
}
export interface LinkedModifierNode extends Node {
type: NodeTypes.LinkedModifier
value: Identifier
/**
* @internal `value` alias
*/
v?: Identifier
}