bsloane1650 commented on a change in pull request #207: Added support for 
enumerations and TypeValueCalc
URL: https://github.com/apache/incubator-daffodil/pull/207#discussion_r275523020
 
 

 ##########
 File path: 
daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/ChoiceCombinator.scala
 ##########
 @@ -70,12 +119,51 @@ case class ChoiceCombinator(ch: ChoiceTermBase, 
rawAlternatives: Seq[Gram])
               "dfdl:choiceBranchKey value (%s) is not unique across all 
branches of a direct dispatch choice. Offending branches are:\n%s",
               k, kvs.map(_._2.context.runtimeData).map(rd => 
rd.diagnosticDebugName + " " + 
rd.schemaFileLocation.locationDescription).mkString("- ", "\n- ", ""))
           }
+          Try(k.toLong) match {
+            case Success(v) => {
+              val asBigInt = BigInt(v)
+              val conflictingRanges = dispatchBranchKeyRangeTuples.filter({ 
case (min, max, _, _) => min.testAsLower(asBigInt) && max.testAsUpper(asBigInt) 
})
+              if (conflictingRanges.length > 0) {
+                SDE(
+                  "dfdl:choiceBranchKey (%s) conflicts with 
dfdl:choiceBranchKeyRanges. Offending branches are:\n%s\n%s",
+                  k,
+                  kvs.map(_._2.context.runtimeData).map(rd => 
rd.diagnosticDebugName + " " + 
rd.schemaFileLocation.locationDescription).mkString("- ", "\n- ", ""),
+                  conflictingRanges.map(_._3.context).map(rd => 
rd.diagnosticDebugName + " " + 
rd.schemaFileLocation.locationDescription).mkString("- ", "\n- ", ""))
+              }
+            }
+            case Failure(_) => ()
 
 Review comment:
   I'll add a comment explaining this.
   
   Essentially, the only point of this try block is to detect when there is an 
overlap between a single choiceBranchKey and a choiceBranchKeyRange. If the 
single choiceBranchKey is not numeric, it cannot be part of a 
choiceBranchKeyRange; and, at the moment, the only numeric type we support for 
keys is integers up to 64 bits.

----------------------------------------------------------------
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