-
Notifications
You must be signed in to change notification settings - Fork 0
/
identifier.go
75 lines (71 loc) · 2.23 KB
/
identifier.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
package conv
import (
"github.com/kaisawind/cobol-go/gen/cobol85"
"github.com/kaisawind/cobol-go/pb"
)
func Identifier(in cobol85.IIdentifierContext) (out *pb.Identifier) {
ctx := in.(*cobol85.IdentifierContext)
out = &pb.Identifier{}
if ictx := ctx.QualifiedDataName(); ictx != nil {
out.OneOf = &pb.Identifier_QualifiedDataName{
QualifiedDataName: QualifiedDataName(ictx),
}
} else if ictx := ctx.TableCall(); ictx != nil {
out.OneOf = &pb.Identifier_TableCall{
TableCall: TableCall(ictx),
}
} else if ictx := ctx.FunctionCall(); ictx != nil {
out.OneOf = &pb.Identifier_FunctionCall{
FunctionCall: FunctionCall(ictx),
}
} else if ictx := ctx.SpecialRegister(); ictx != nil {
out.OneOf = &pb.Identifier_SpecialRegister{
SpecialRegister: &pb.SpecialRegister{},
}
}
return
}
func FunctionCall(in cobol85.IFunctionCallContext) (out *pb.FunctionCall) {
ctx := in.(*cobol85.FunctionCallContext)
args := []*pb.Argument{}
for _, v := range ctx.AllArgument() {
args = append(args, Argument(v))
}
out = &pb.FunctionCall{
FunctionName: FunctionName(ctx.FunctionName()),
Arguments: args,
ReferenceModifier: ReferenceModifier(ctx.ReferenceModifier()),
}
return
}
func Argument(in cobol85.IArgumentContext) (out *pb.Argument) {
ctx := in.(*cobol85.ArgumentContext)
if ictx := ctx.Identifier(); ictx != nil {
out.OneOf = &pb.Argument_Identifier{
Identifier: Identifier(ictx),
}
} else if ictx := ctx.Literal(); ictx != nil {
out.OneOf = &pb.Argument_Literal{
Literal: Literal(ictx),
}
} else if ictx := ctx.QualifiedDataName(); ictx != nil {
out.OneOf = &pb.Argument_QualifiedDataName{
QualifiedDataName: &pb.QualifiedDataNameIntegerLiteral{
QualifiedDataName: QualifiedDataName(ctx.QualifiedDataName()),
IntegerLiteral: IntegerLiteral(ctx.IntegerLiteral()),
},
}
} else if ictx := ctx.IndexName(); ictx != nil {
out.OneOf = &pb.Argument_IndexName{
IndexName: &pb.IndexNameIntegerLiteral{
IndexName: IndexName(ctx.IndexName()),
IntegerLiteral: IntegerLiteral(ctx.IntegerLiteral()),
},
}
} else if ictx := ctx.ArithmeticExpression(); ictx != nil {
out.OneOf = &pb.Argument_ArithmeticExpression{
ArithmeticExpression: &pb.ArithmeticExpression{},
}
}
return
}