bsloane1650 commented on a change in pull request #240: Add 
dfdlx:choiceBranchKeyRanges
URL: https://github.com/apache/incubator-daffodil/pull/240#discussion_r295869182
 
 

 ##########
 File path: 
daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/ChoiceCombinator.scala
 ##########
 @@ -113,17 +122,17 @@ case class ChoiceCombinator(ch: ChoiceTermBase, 
alternatives: Seq[Gram])
       //Since there is not a choiceBranchKeyRanges attribute, this can only 
currently be populated by repType
       val dispatchBranchKeyRangeTuples: Seq[(RangeBound[BigInt], 
RangeBound[BigInt], Parser, Boolean)] = alternatives.flatMap { alt =>
         val keyTerm = alt.context.asInstanceOf[Term]
-        val branchKeyRanges:Set[(RangeBound[BigInt],RangeBound[BigInt])] = 
ch.defaultableChoiceBranchKeyKind match {
+        val branchKeyRanges:Seq[(RangeBound[BigInt],RangeBound[BigInt])] = 
ch.defaultableChoiceBranchKeyKind match {
           case ChoiceKeyKindType.ByType => {
             val keyTerm_ = keyTerm.asInstanceOf[ElementBase]
-            keyTerm_.simpleType.optRepValueSet.get.valueRanges.map(x=>{
+            keyTerm_.simpleType.optRepValueSet.get.valueRanges.toSeq.map(x=>{
               val x_ = x.asInstanceOf[(RangeBound[BigInt],RangeBound[BigInt])]
               (x_._1,x_._2)
             })
           }
-          case ChoiceKeyKindType.Explicit    => Set()
-          case ChoiceKeyKindType.Implicit    => Set()
-          case ChoiceKeyKindType.Speculative => Set()
+          case ChoiceKeyKindType.Explicit | ChoiceKeyKindType.Implicit    => 
+            
IntRangeCooker.convertConstant(keyTerm.findPropertyOption("choiceBranchKeyRanges").toOption.getOrElse(""),
 context, false)
+          case ChoiceKeyKindType.Speculative => Assert.invariantFailed("Cannot 
have choiceKeyKind==speculative with direct dispatch")
 
 Review comment:
   Looking closer at this, I'm not actually sure how to write this error 
message.
   
   What is happening is we have 2 potential sources for branch keys. Either we 
get the branch keys from the dfdl:choiceBranchKey and 
dfdlx:choiceBranchKeyRanges attributes, or we get the branch keys from the 
dfdlx:repValues and dfdlx:repValueRanges attributes of the underlying types.
   
   To avoid duplication, we first get the keys and keyRanges from either 
source, then have a single codepath do the validation. This means that at the 
point where we emit these errors, the problem could be in either the 
choiceBranchKey(Ranges) attributes, or in the repValue(Ranges) attributes.
   
   We should still be able to distinguish these two cases by using the 
ch.defaultableChoiceBranchKeyKind value.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to