-
Notifications
You must be signed in to change notification settings - Fork 22
/
fields.ts
120 lines (109 loc) · 2.31 KB
/
fields.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
import { Span, Token } from "../parser/recursive-descent-parser.ts";
import { MalformedBase, Option, OptionName, StatementBase } from "./index.ts";
import {
Comma,
Constant,
Empty,
IntLit,
Keyword,
Semi,
Type,
} from "./lexical-elements.ts";
import { MessageBody } from "./top-level-definitions.ts";
export type Node =
| Field
| MalformedField
| FieldOptions
| FieldOption
| Group
| Oneof
| OneofBody
| OneofField
| OneofGroup
| MapField;
export interface Field extends StatementBase {
type: "field";
fieldLabel?: Keyword;
fieldType: Type;
fieldName: Token;
eq: Token;
fieldNumber: IntLit;
fieldOptions?: FieldOptions;
semi: Semi;
}
export type MalformedField = MalformedBase<
Field,
"malformed-field",
| "fieldLabel"
| "fieldType"
>;
export interface FieldOptions extends Span {
type: "field-options";
bracketOpen: Token;
fieldOptionOrCommas: (FieldOption | Comma)[];
bracketClose: Token;
}
export interface FieldOption extends Span {
type: "field-option";
optionName: OptionName;
eq: Token;
constant: Constant;
}
export interface Group extends StatementBase {
type: "group";
groupLabel: Keyword;
keyword: Keyword;
groupName: Token;
eq: Token;
fieldNumber: IntLit;
fieldOptions?: FieldOptions;
messageBody: MessageBody;
}
export interface Oneof extends StatementBase {
type: "oneof";
keyword: Keyword;
oneofName: Token;
oneofBody: OneofBody;
}
export interface OneofBody extends Span {
type: "oneof-body";
bracketOpen: Token;
statements: OneofBodyStatement[];
bracketClose: Token;
}
export type OneofBodyStatement =
| Option
| OneofField
| OneofGroup
| Empty;
export interface OneofField extends StatementBase {
type: "oneof-field";
fieldType: Type;
fieldName: Token;
eq: Token;
fieldNumber: IntLit;
fieldOptions?: FieldOptions;
semi: Semi;
}
export interface OneofGroup extends StatementBase {
type: "oneof-group";
keyword: Keyword;
groupName: Token;
eq: Token;
fieldNumber: IntLit;
messageBody: MessageBody;
}
export interface MapField extends StatementBase {
type: "map-field";
keyword: Keyword;
typeBracketOpen: Token;
keyType: Type;
typeSep: Token;
valueType: Type;
typeBracketClose: Token;
mapName: Token;
eq: Token;
fieldNumber: IntLit;
fieldOptions?: FieldOptions;
semi: Semi;
}