[
https://issues.apache.org/jira/browse/DAFFODIL-3021?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18012566#comment-18012566
]
Steve Lawrence commented on DAFFODIL-3021:
------------------------------------------
I believe the C code generator only supports dfdl:occursCountKind="fixed" and
dfdl:occursCountKind="expression". With this, it knows exactly how many
elements will be parsed, either at compile time or parse time. This avoids the
need for any kind of speculative parsing where it might need to backtrack since
it doesn't know where the array ends. Daffodil Scala supports backtracking but
the generated C code does not. Most binary data (which is what the code
generator was designed to support) either has fixed length arrays or simple
expressions to calculate the array length, so this has been sufficient so far.
So implicit or parsed length arrays would likely take some effort to
generically support. If possible, maybe you can rewrite your schema using fixed
or expression length arrays? Here is an example schema that uses a simple
expression and a fixed length array
https://github.com/apache/daffodil/blob/b05b82f481641c2e50472e8408ec79ca646bc14f/daffodil-codegen-c/src/test/resources/org/apache/daffodil/codegen/c/variablelen.dfdl.xsd#L89-L102
If that doesn't work, it might be easier (though not necessarily easy) to add
support for implicit/parsed arrays in specific circumstances. For example, as
the last element of the schema, or maybe as the last element of of an explicit
length complex type. In these cases you don't technically need to support
backtracking since you can just keep parsing until you either run out of data
or hit the end of the parents fixed length.
I don't think any current daffodil devs have time to work on the code
generator, but if you're interesting in adding one of these kinds of features
or maybe some other limited form of implicit/parse to the code generator,
please let us know. We'd be happy to help spin you up on the code base and get
you started.
> Unbounded occurrences in C code generation
> ------------------------------------------
>
> Key: DAFFODIL-3021
> URL: https://issues.apache.org/jira/browse/DAFFODIL-3021
> Project: Daffodil
> Issue Type: Request
> Reporter: Ben Cavanagh
> Priority: Major
> Attachments: schema.dfdl.xsd
>
>
> Wanted to request (or ask whether it is possible through some other method)
> the ability to generate C code which is capable of handling unbounded
> occurrences of a type. I've attached a schema which parses strings of "0"s of
> unbounded length.
> I have also tried setting a high bound for maxOccurs and the code
> successfully generates but does not make.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)