-
Notifications
You must be signed in to change notification settings - Fork 0
/
file_description_entry.go
187 lines (185 loc) · 7.37 KB
/
file_description_entry.go
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
package conv
import (
"github.com/kaisawind/cobol-go/gen/cobol85"
"github.com/kaisawind/cobol-go/pb"
)
func FileDescriptionEntry(in cobol85.IFileDescriptionEntryContext) (out *pb.FileDescriptionEntry) {
ctx := in.(*cobol85.FileDescriptionEntryContext)
out = &pb.FileDescriptionEntry{
FileName: FileName(ctx.FileName()),
}
for _, ictx := range ctx.AllFileDescriptionEntryClause() {
cctx := ictx.(*cobol85.FileDescriptionEntryClauseContext)
if iClause := cctx.ExternalClause(); iClause != nil {
out.ExternalClause = &pb.ExternalClause{}
} else if iClause := cctx.GlobalClause(); iClause != nil {
out.GlobalClause = &pb.GlobalClause{}
} else if iClause := cctx.BlockContainsClause(); iClause != nil {
cCtx := iClause.(*cobol85.BlockContainsClauseContext)
var unit pb.BlockContainsClause_Unit
switch {
case cCtx.RECORDS() != nil:
unit = pb.BlockContainsClause_RECORDS
case cCtx.CHARACTERS() != nil:
unit = pb.BlockContainsClause_CHARACTERS
}
out.BlockContainsClause = &pb.BlockContainsClause{
From: IntegerLiteral(cCtx.IntegerLiteral()),
To: IntegerLiteral(cCtx.IntegerLiteral()),
Unit: unit,
}
} else if iClause := cctx.RecordContainsClause(); iClause != nil {
cCtx := iClause.(*cobol85.RecordContainsClauseContext)
out.RecordContainsClause = &pb.RecordContainsClause{}
if iFormat := cCtx.RecordContainsClauseFormat1(); iFormat != nil {
fCtx := iFormat.(*cobol85.RecordContainsClauseFormat1Context)
out.RecordContainsClause.From = IntegerLiteral(fCtx.IntegerLiteral())
} else if iFormat := cCtx.RecordContainsClauseFormat2(); iFormat != nil {
fCtx := iFormat.(*cobol85.RecordContainsClauseFormat2Context)
out.RecordContainsClause.From = IntegerLiteral(fCtx.IntegerLiteral())
out.RecordContainsClause.Varying = true
if iTo := fCtx.RecordContainsTo(); iTo != nil {
toCtx := iTo.(*cobol85.RecordContainsToContext)
out.RecordContainsClause.To = IntegerLiteral(toCtx.IntegerLiteral())
}
if fCtx.QualifiedDataName() != nil {
out.RecordContainsClause.QualifiedDataName = QualifiedDataName(fCtx.QualifiedDataName())
}
} else if iFormat := cCtx.RecordContainsClauseFormat3(); iFormat != nil {
fCtx := iFormat.(*cobol85.RecordContainsClauseFormat3Context)
out.RecordContainsClause.From = IntegerLiteral(fCtx.IntegerLiteral())
if iTo := fCtx.RecordContainsTo(); iTo != nil {
toCtx := iTo.(*cobol85.RecordContainsToContext)
out.RecordContainsClause.To = IntegerLiteral(toCtx.IntegerLiteral())
}
}
} else if iClause := cctx.LabelRecordsClause(); iClause != nil {
cCtx := iClause.(*cobol85.LabelRecordsClauseContext)
out.LabelRecordsClause = &pb.LabelRecordsClause{}
switch {
case cCtx.OMITTED() != nil:
out.LabelRecordsClause.OneOf = &pb.LabelRecordsClause_Type_{
Type: pb.LabelRecordsClause_OMITTED,
}
case cCtx.STANDARD() != nil:
out.LabelRecordsClause.OneOf = &pb.LabelRecordsClause_Type_{
Type: pb.LabelRecordsClause_STANDARD,
}
case len(cCtx.AllDataName()) != 0:
names := []*pb.DataName{}
for _, ia := range cCtx.AllDataName() {
names = append(names, DataName(ia))
}
out.LabelRecordsClause.OneOf = &pb.LabelRecordsClause_DataNames_{
DataNames: &pb.LabelRecordsClause_DataNames{
DataNames: names,
},
}
}
} else if iClause := cctx.ValueOfClause(); iClause != nil {
cCtx := iClause.(*cobol85.ValueOfClauseContext)
out.ValueOfClause = &pb.ValueOfClause{}
for _, ia := range cCtx.AllValuePair() {
vpCtx := ia.(*cobol85.ValuePairContext)
vp := &pb.ValuePair{
SystemName: SystemName(vpCtx.SystemName()),
}
if vpCtx.QualifiedDataName() != nil {
vp.Value = &pb.ValuePair_QualifiedDataName{
QualifiedDataName: QualifiedDataName(vpCtx.QualifiedDataName()),
}
} else if vpCtx.Literal() != nil {
vp.Value = &pb.ValuePair_Literal{
Literal: Literal(vpCtx.Literal()),
}
}
}
} else if iClause := cctx.DataRecordsClause(); iClause != nil {
cCtx := iClause.(*cobol85.DataRecordsClauseContext)
out.DataRecordsClause = &pb.DataRecordsClause{}
for _, iDataName := range cCtx.AllDataName() {
out.DataRecordsClause.DataNames = append(out.DataRecordsClause.DataNames, DataName(iDataName))
}
} else if iClause := cctx.LinageClause(); iClause != nil {
cCtx := iClause.(*cobol85.LinageClauseContext)
out.LinageClause = &pb.LinageClause{}
nofl := &pb.DataNameOrIntegerLiteral{}
if cCtx.DataName() != nil {
nofl.OneOf = &pb.DataNameOrIntegerLiteral_DataName{
DataName: DataName(cCtx.DataName()),
}
} else if cCtx.IntegerLiteral() != nil {
nofl.OneOf = &pb.DataNameOrIntegerLiteral_IntegerLiteral{
IntegerLiteral: IntegerLiteral(cCtx.IntegerLiteral()),
}
}
out.LinageClause.NumberOfLines = nofl
for _, iAt := range cCtx.AllLinageAt() {
atCtx := iAt.(*cobol85.LinageAtContext)
if ilat := atCtx.LinageFootingAt(); ilat != nil {
lat := ilat.(*cobol85.LinageFootingAtContext)
nofl := &pb.DataNameOrIntegerLiteral{}
if lat.DataName() != nil {
nofl.OneOf = &pb.DataNameOrIntegerLiteral_DataName{
DataName: DataName(lat.DataName()),
}
} else if lat.IntegerLiteral() != nil {
nofl.OneOf = &pb.DataNameOrIntegerLiteral_IntegerLiteral{
IntegerLiteral: IntegerLiteral(lat.IntegerLiteral()),
}
}
out.LinageClause.FootingAt = nofl
} else if ilat := atCtx.LinageLinesAtTop(); ilat != nil {
lat := ilat.(*cobol85.LinageLinesAtTopContext)
nofl := &pb.DataNameOrIntegerLiteral{}
if lat.DataName() != nil {
nofl.OneOf = &pb.DataNameOrIntegerLiteral_DataName{
DataName: DataName(lat.DataName()),
}
} else if lat.IntegerLiteral() != nil {
nofl.OneOf = &pb.DataNameOrIntegerLiteral_IntegerLiteral{
IntegerLiteral: IntegerLiteral(lat.IntegerLiteral()),
}
}
out.LinageClause.LinesAtTop = nofl
} else if ilat := atCtx.LinageLinesAtBottom(); ilat != nil {
lat := ilat.(*cobol85.LinageLinesAtBottomContext)
nofl := &pb.DataNameOrIntegerLiteral{}
if lat.DataName() != nil {
nofl.OneOf = &pb.DataNameOrIntegerLiteral_DataName{
DataName: DataName(lat.DataName()),
}
} else if lat.IntegerLiteral() != nil {
nofl.OneOf = &pb.DataNameOrIntegerLiteral_IntegerLiteral{
IntegerLiteral: IntegerLiteral(lat.IntegerLiteral()),
}
}
out.LinageClause.LinesAtBottom = nofl
}
}
} else if iClause := cctx.CodeSetClause(); iClause != nil {
cCtx := iClause.(*cobol85.CodeSetClauseContext)
out.CodeSetClause = &pb.CodeSetClause{
AlphabetName: AlphabetName(cCtx.AlphabetName()),
}
} else if iClause := cctx.ReportClause(); iClause != nil {
cCtx := iClause.(*cobol85.ReportClauseContext)
out.ReportClause = &pb.ReportClause{}
for _, iReport := range cCtx.AllReportName() {
out.ReportClause.ReportNames = append(out.ReportClause.ReportNames, ReportName(iReport))
}
} else if iClause := cctx.RecordingModeClause(); iClause != nil {
cCtx := iClause.(*cobol85.RecordingModeClauseContext)
msCtx := cCtx.ModeStatement().(*cobol85.ModeStatementContext)
out.RecordingModeClause = &pb.RecordingModeClause{
ModeStatement: &pb.ModeStatement{
CobolWord: CobolWord(msCtx.CobolWord()),
},
}
}
}
for _, ictx := range ctx.AllDataDescriptionEntry() {
out.DataDescriptionEntries = append(out.DataDescriptionEntries, DataDescriptionEntry(ictx))
}
return
}