mbeckerle commented on code in PR #987:
URL: https://github.com/apache/daffodil/pull/987#discussion_r1911310436
##########
daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/parsers/Parser.scala:
##########
@@ -227,26 +227,47 @@ abstract class CombinatorParser(override val context:
RuntimeData)
extends Parser
with CombinatorProcessor
-final class SeqCompParser(context: RuntimeData, val childParsers:
Vector[Parser])
- extends CombinatorParser(context) {
+final class SeqCompParser(
+ context: RuntimeData,
+ val childParsers: Vector[Parser],
+) extends CombinatorParser(context) {
override lazy val runtimeDependencies = Vector()
override def childProcessors = childParsers
override def nom = "seq"
- val numChildParsers = childParsers.size
+ val assertDiscrimExpressions = childParsers.collect { case ae:
AssertExpressionEvaluationParser => ae }
+ val discrimExpressions = assertDiscrimExpressions.filter { _.discrim }
+ val assertExpressions = assertDiscrimExpressions.filterNot { _.discrim }
+ val nonAssertChildren = childParsers.diff(assertExpressions)
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
+
+ // Handle all non assert/discriminator child parsers first
+ while ((i < nonAssertChildren.size) && (pstate.processorStatus eq
Success)) {
+ nonAssertChildren(i).parse1(pstate)
+ i += 1
+ }
+
+ // Handle all discriminator expressions statements after sequence body
+ i = 0
+ while (i < discrimExpressions.size) {
Review Comment:
Only one discriminator at each annotation point. In fact I'm not sure we
enforce this, but one annotation point is supposed to have only a discriminator
OR asserts (1 or more), but not both:
Section 7.6: "The resolved set of statement annotations for a schema
component can contain only a single dfdl:discriminator or one or more
dfdl:assert annotations, but not both. To clarify: dfdl:assert annotations and
dfdl:discriminator annotations are exclusive of each other. It is a Schema
Definition Error otherwise."
--
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]