stevedlawrence commented on code in PR #987:
URL: https://github.com/apache/daffodil/pull/987#discussion_r2310888439


##########
daffodil-core/src/main/scala/org/apache/daffodil/runtime1/processors/parsers/Parser.scala:
##########
@@ -227,26 +227,25 @@ abstract class CombinatorParser(override val context: 
RuntimeData)
   extends Parser
   with CombinatorProcessor
 
-final class SeqCompParser(context: RuntimeData, val childParsers: 
Array[Parser])
-  extends CombinatorParser(context) {
+final class SeqCompParser(
+  context: RuntimeData,
+  val childParsers: Array[Parser],
+  testAssert: Array[Parser]
+) extends CombinatorParser(context) {
   override def runtimeDependencies = Vector()
   override def childProcessors = childParsers.toVector
 
   override def nom = "seq"
 
-  val numChildParsers = childParsers.size
-
   def parse(pstate: PState): Unit = {
-    var i: Int = 0
-    while (i < numChildParsers) {
-      val parser = childParsers(i)
-      parser.parse1(pstate)
-      if (pstate.processorStatus ne Success)
-        return
-      i += 1
+    childParsers.foreach { cp =>
+      if (pstate.processorStatus.isSuccess) cp.parse1(pstate)
+      else cp match {
+        case ae: AssertExpressionEvaluationParser if (ae.discrim) => 
pstate.withTempSuccess(ae.parse1)
+        case _ => // processorStatus is Failure, do not execute non-discim 
child parsers
+      }

Review Comment:
   My comment was in regards to the changes that Josh made that have since been 
reverted. If I recall, the change was essentially something like
   
   ```scala
   childParsers.foreach { p =>
     if (state.isSuccess || p.isDiscriminator ) {
       p.parse(state)
     }
   }
   ```
   
   So if one of the early `p.parse()` failed it would still iterate over every 
child parser even though it only needs to evaluate the discriminator.
   
   I don't tthink the code in the current PR does that.



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to