-
Notifications
You must be signed in to change notification settings - Fork 22
/
top-level-definitions.ts
152 lines (134 loc) · 2.73 KB
/
top-level-definitions.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import { Span, Token } from "../parser/recursive-descent-parser.ts";
import { Extensions, Reserved } from "./extensions-and-reserved.ts";
import {
Field,
FieldOptions,
Group,
MalformedField,
MapField,
Oneof,
} from "./fields.ts";
import { Option, StatementBase } from "./index.ts";
import {
Empty,
Keyword,
Semi,
SignedIntLit,
Type,
} from "./lexical-elements.ts";
export type Node =
| Enum
| EnumBody
| EnumField
| Message
| MessageBody
| Extend
| ExtendBody
| Service
| ServiceBody
| Rpc
| RpcBody;
export interface Enum extends StatementBase {
type: "enum";
keyword: Keyword;
enumName: Token;
enumBody: EnumBody;
}
export interface EnumBody extends Span {
type: "enum-body";
bracketOpen: Token;
statements: EnumBodyStatement[];
bracketClose: Token;
}
export type EnumBodyStatement =
| Option
| Reserved
| EnumField
| Empty;
export interface EnumField extends StatementBase {
type: "enum-field";
fieldName: Token;
eq: Token;
fieldNumber: SignedIntLit;
fieldOptions?: FieldOptions;
semi: Semi;
}
export interface Message extends StatementBase {
type: "message";
keyword: Keyword;
messageName: Token;
messageBody: MessageBody;
}
export interface MessageBody extends Span {
type: "message-body";
bracketOpen: Token;
statements: MessageBodyStatement[];
bracketClose: Token;
}
export type MessageBodyStatement =
| Field
| MalformedField
| Enum
| Message
| Extend
| Extensions
| Group
| Option
| Oneof
| MapField
| Reserved
| Empty;
export interface Extend extends StatementBase {
type: "extend";
keyword: Keyword;
messageType: Type;
extendBody: ExtendBody;
}
export interface ExtendBody extends Span {
type: "extend-body";
bracketOpen: Token;
statements: ExtendBodyStatement[];
bracketClose: Token;
}
export type ExtendBodyStatement =
| Field
| MalformedField
| Group
| Empty;
export interface Service extends StatementBase {
type: "service";
keyword: Keyword;
serviceName: Token;
serviceBody: ServiceBody;
}
export interface ServiceBody extends Span {
type: "service-body";
bracketOpen: Token;
statements: ServiceBodyStatement[];
bracketClose: Token;
}
export type ServiceBodyStatement = Option | Rpc | Empty;
export interface Rpc extends StatementBase {
type: "rpc";
keyword: Keyword;
rpcName: Token;
reqType: RpcType;
returns: Token;
resType: RpcType;
semiOrRpcBody: Semi | RpcBody;
}
export interface RpcBody extends Span {
type: "rpc-body";
bracketOpen: Token;
statements: RpcBodyStatement[];
bracketClose: Token;
}
export type RpcBodyStatement =
| Option
| Empty;
export interface RpcType extends Span {
bracketOpen: Token;
stream?: Keyword;
messageType: Type;
bracketClose: Token;
}