@@ -874,66 +874,87 @@ extension Parser {
874
874
875
875
extension Parser {
876
876
mutating func parsePackageAttributeArguments( ) -> RawPackageAttributeArgumentsSyntax {
877
- // Parsing package location.
877
+ // Parsing package description
878
878
let ( unexpectedBeforeLocationLabel, locationLabel) = self . expectAny ( [ . keyword( . id) , . keyword( . path) , . keyword( . url) ] , default: . keyword( . id) )
879
879
let ( unexpectedBeforeLocationColon, locationColon) = self . expect ( . colon)
880
880
let location = self . parseStringLiteral ( )
881
- // Parsing package requirement.
882
- let ( unexpectedBeforeRequirementComma, requirementComma) : ( RawUnexpectedNodesSyntax ? , RawTokenSyntax ? )
883
- let ( unexpectedBeforeRequirementLabel, requirementLabel) : ( RawUnexpectedNodesSyntax ? , RawTokenSyntax ? )
884
- let ( unexpectedBeforeRequirementColon, requirementColon) : ( RawUnexpectedNodesSyntax ? , RawTokenSyntax ? )
885
- let requirement : RawExprSyntax ?
886
- if locationLabel. tokenKind != . keyword( . path) {
887
- ( unexpectedBeforeRequirementComma, requirementComma) = self . expect ( . comma)
881
+ let packageDescription : RawPackageAttributeArgumentsSyntax . Description
882
+ if locationLabel. tokenKind == . keyword( . path) {
883
+ packageDescription = . local(
884
+ RawLocalPackageDescriptionSyntax (
885
+ unexpectedBeforeLocationLabel,
886
+ label: locationLabel,
887
+ unexpectedBeforeLocationColon,
888
+ colon: locationColon,
889
+ path: location,
890
+ arena: self . arena
891
+ )
892
+ )
893
+ } else {
894
+ let ( unexpectedBeforeRequirementComma, requirementComma) = self . expect ( . comma)
888
895
if self . at ( any: [ . colon, . keyword( . from) , . keyword( . exact) , . keyword( . branch) , . keyword( . revision) ] ) {
889
- ( unexpectedBeforeRequirementLabel, requirementLabel) = self . expectAny ( [ . keyword( . from) , . keyword( . exact) , . keyword( . branch) , . keyword( . revision) ] , default: . keyword( . from) )
890
- ( unexpectedBeforeRequirementColon, requirementColon) = self . expect ( . colon)
891
- requirement = self . parseStringLiteral ( ) . as ( RawExprSyntax . self)
896
+ let ( unexpectedBeforeRequirementLabel, requirementLabel) = self . expectAny ( [ . keyword( . from) , . keyword( . exact) , . keyword( . branch) , . keyword( . revision) ] , default: . keyword( . from) )
897
+ let ( unexpectedBeforeRequirementColon, requirementColon) = self . expect ( . colon)
898
+ let requirement = self . parseStringLiteral ( ) . as ( RawExprSyntax . self) !
899
+ packageDescription = . remote(
900
+ RawRemotePackageDescriptionSyntax (
901
+ unexpectedBeforeLocationLabel,
902
+ locationLabel: locationLabel,
903
+ unexpectedBeforeLocationColon,
904
+ locationColon: locationColon,
905
+ location: location,
906
+ unexpectedBeforeRequirementComma,
907
+ comma: requirementComma,
908
+ unexpectedBeforeRequirementLabel,
909
+ requirementLabel: requirementLabel,
910
+ unexpectedBeforeRequirementColon,
911
+ requirementColon: requirementColon,
912
+ requirement: requirement,
913
+ arena: self . arena
914
+ )
915
+ )
892
916
} else {
893
- ( unexpectedBeforeRequirementLabel, requirementLabel) = ( nil , nil )
894
- ( unexpectedBeforeRequirementColon, requirementColon) = ( nil , nil )
895
- requirement = self . parseExpression ( )
917
+ let requirement = self . parseExpression ( )
918
+ packageDescription = . remote(
919
+ RawRemotePackageDescriptionSyntax (
920
+ unexpectedBeforeLocationLabel,
921
+ locationLabel: locationLabel,
922
+ unexpectedBeforeLocationColon,
923
+ locationColon: locationColon,
924
+ location: location,
925
+ unexpectedBeforeRequirementComma,
926
+ comma: requirementComma,
927
+ requirementLabel: nil ,
928
+ requirementColon: nil ,
929
+ requirement: requirement,
930
+ arena: self . arena
931
+ )
932
+ )
896
933
}
897
- } else {
898
- ( unexpectedBeforeRequirementComma, requirementComma) = ( nil , nil )
899
- ( unexpectedBeforeRequirementLabel, requirementLabel) = ( nil , nil )
900
- ( unexpectedBeforeRequirementColon, requirementColon) = ( nil , nil )
901
- requirement = nil
902
934
}
903
- // Parsing package requirement.
904
- let productComma = self . consume ( if: . comma)
905
- let ( unexpectedBeforeProductLabel, productLabel) : ( RawUnexpectedNodesSyntax ? , RawTokenSyntax ? )
906
- let ( unexpectedBeforeProductColon, productColon) : ( RawUnexpectedNodesSyntax ? , RawTokenSyntax ? )
907
- let productName : RawStringLiteralExprSyntax ?
908
- if productComma != nil {
909
- ( unexpectedBeforeProductLabel, productLabel) = self . expect ( . keyword( . product) )
910
- ( unexpectedBeforeProductColon, productColon) = self . expect ( . colon)
911
- productName = self . parseStringLiteral ( )
935
+ // Parsing package product
936
+ let comma = self . consume ( if: . comma)
937
+ let packageProduct : RawPackageProductSyntax ?
938
+ if comma != nil {
939
+ let ( unexpectedBeforeProductLabel, productLabel) = self . expect ( . keyword( . product) )
940
+ let ( unexpectedBeforeProductColon, productColon) = self . expect ( . colon)
941
+ let productName = self . parseStringLiteral ( )
942
+ packageProduct = RawPackageProductSyntax (
943
+ unexpectedBeforeProductLabel,
944
+ label: productLabel,
945
+ unexpectedBeforeProductColon,
946
+ colon: productColon,
947
+ name: productName,
948
+ arena: self . arena
949
+ )
912
950
} else {
913
- ( unexpectedBeforeProductLabel, productLabel) = ( nil , nil )
914
- ( unexpectedBeforeProductColon, productColon) = ( nil , nil )
915
- productName = nil
951
+ packageProduct = nil
916
952
}
917
953
// Returning @_package argument list
918
954
return RawPackageAttributeArgumentsSyntax (
919
- unexpectedBeforeLocationLabel,
920
- locationLabel: locationLabel,
921
- unexpectedBeforeLocationColon,
922
- locationColon: locationColon,
923
- location: location,
924
- unexpectedBeforeRequirementComma,
925
- requirementComma: requirementComma,
926
- unexpectedBeforeRequirementLabel,
927
- requirementLabel: requirementLabel,
928
- unexpectedBeforeRequirementColon,
929
- requirementColon: requirementColon,
930
- requirement: requirement,
931
- productComma: productComma,
932
- unexpectedBeforeProductLabel,
933
- productLabel: productLabel,
934
- unexpectedBeforeProductColon,
935
- productColon: productColon,
936
- productName: productName,
955
+ description: packageDescription,
956
+ comma: comma,
957
+ product: packageProduct,
937
958
arena: self . arena
938
959
)
939
960
}
0 commit comments