mbeckerle commented on a change in pull request #143: Support
dfdl:length="prefixed"
URL: https://github.com/apache/incubator-daffodil/pull/143#discussion_r239928284
##########
File path:
daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/BinaryNumberTraits.scala
##########
@@ -50,3 +56,63 @@ trait HasRuntimeExplicitLength {
nBytes * toBits
}
}
+
+
+trait PrefixedLengthParserMixin {
+
+ def prefixedLengthParser: Parser
+ def prefixedLengthERD: ElementRuntimeData
+ def lengthUnits: LengthUnits
+ def prefixedLengthAdjustmentInUnits: Long
Review comment:
Ok, looks like your code is correct.
Hmm. I just reread the spec. It is narrower than I recall. It prohibits, for
example this rep:
123|...string of length 123 bytes...
Where the 123 is delimited by the "|". I believe I've actually seen this
somewhere.
It does allow
123...string of length 123...
where the 123 is a fixed-length text string of length 3 bytes.
Based on what it says in the spec. the only way the prefix itself can be
variable length is if it itself is this nested-prefix-length thing where the
prefix length itself has a prefix length. There's exactly one case of that in
the world and it's related to an ASN.1 feature.
I suspect this is a mistake in the spec. In general the prefix fields
themselves can be variable length.
At least lengthKind 'delimited' is needed, and the special case of the
prefix itself having a prefix is supposed to the "wierd thing" that can happen
in addition to all the other ways the prefix itself could be variable length.
But that will have to get fixed in a rev of the DFDL spec. For now what you
have seems to match the spec. so good enough.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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