@@ -20,8 +20,9 @@ extension PrecedenceGroup {
20
20
self . syntax = syntax
21
21
22
22
for attr in syntax. groupAttributes {
23
+ switch attr. as ( SyntaxEnum . self) {
23
24
// Relation (lowerThan, higherThan)
24
- if let relation = attr . as ( PrecedenceGroupRelationSyntax . self ) {
25
+ case . precedenceGroupRelation ( let relation) :
25
26
let isLowerThan = relation. higherThanOrLowerThan. text == " lowerThan "
26
27
for otherGroup in relation. otherNames {
27
28
let otherGroupName = otherGroup. name. text
@@ -32,17 +33,12 @@ extension PrecedenceGroup {
32
33
self . relations. append ( relation)
33
34
}
34
35
35
- continue
36
- }
37
-
38
36
// Assignment
39
- if let assignment = attr . as ( PrecedenceGroupAssignmentSyntax . self ) {
37
+ case . precedenceGroupAssignment ( let assignment) :
40
38
self . assignment = assignment. flag. text == " true "
41
- continue
42
- }
43
39
44
40
// Associativity
45
- if let associativity = attr . as ( PrecedenceGroupAssociativitySyntax . self ) {
41
+ case . precedenceGroupAssociativity ( let associativity) :
46
42
switch associativity. value. text {
47
43
case " left " :
48
44
self . associativity = . left
@@ -56,6 +52,9 @@ extension PrecedenceGroup {
56
52
default :
57
53
break
58
54
}
55
+
56
+ default :
57
+ break
59
58
}
60
59
}
61
60
}
@@ -68,15 +67,9 @@ extension Operator {
68
67
init ( from syntax: OperatorDeclSyntax ) {
69
68
self . syntax = syntax
70
69
71
- let kindModifier = syntax. modifiers? . first { modifier in
72
- OperatorKind ( rawValue: modifier. name. text) != nil
73
- }
74
-
75
- if let kindModifier = kindModifier {
76
- kind = OperatorKind ( rawValue: kindModifier. name. text) !
77
- } else {
78
- kind = . infix
79
- }
70
+ kind = syntax. modifiers? . compactMap {
71
+ OperatorKind ( rawValue: $0. name. text)
72
+ } . first ?? . infix
80
73
81
74
name = syntax. identifier. text
82
75
0 commit comments