mbeckerle commented on code in PR #987:
URL: https://github.com/apache/daffodil/pull/987#discussion_r2310905439
##########
daffodil-core/src/main/scala/org/apache/daffodil/runtime1/processors/parsers/Parser.scala:
##########
@@ -227,26 +227,38 @@ 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
+ val optDiscrimParser = childParsers.collectFirst {
+ case ae: AssertExpressionEvaluationParser if (ae.discrim) => ae
+ }
+ val nonDiscrimChildren = childParsers.diff(optDiscrimParser.toSeq)
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
+ var i = 0
+ val numNonDiscrimChildren = nonDiscrimChildren.size
+
+ // Handle all non discriminator child parsers first
+ while ((i < numNonDiscrimChildren) && (pstate.processorStatus eq Success))
{
+ nonDiscrimChildren(i).parse1(pstate)
i += 1
}
- }
+ if (optDiscrimParser.isDefined) {
Review Comment:
Comments are needed here to motivate this final execution of the
optDiscrimParser even if there was a prior failure.
Cite the DFDL v1.0 spec section.
--
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]