stevedlawrence commented on PR #901:
URL: https://github.com/apache/daffodil/pull/901#issuecomment-1382229205

   I think I've potentially tracked down part of the issue. In 
`elementParseAndUnspecifiedLengthGenerateCode`, we have this logic for complex 
types:
   ```
         context.elementChildren.foreach { child =>
           cgState.addFieldDeclaration(context, child) // struct member for 
child
           cgState.addComputations(child) // offset, ERD computations
           cgState.addPerChildStatements(child) // initERD, parseSelf, 
unparseSelf for child
         }
   ```
   So this is iterating over each child of the complex type. But that only 
includes actual element children, and so it skips over any other children (like 
the sequence) that are part of the content of the complex type.
   
   I'm not exactly sure how to fix this since I'm not too familiar with the 
code generator, but it feels like in this complex case, you instead want do 
something like `Runtime2CodeGenerator.generateCode(elementContentGram, 
cgState)` to recurse into the content gram of the complex element. This should 
recursively walk into the children to generate their individual parse/unparse 
code instead of doing it all in this loop.
   
   Note that if you do this, then I think you'll actually start to walk into 
AlignmentFill grammars. Then you won't even need to check for 
`isKnownToBeAligned` because Daffodil has already done it and optimized out any 
AlignmentFill grammars where alignment is known. So if if your code generator 
ever walks to this grammar then you just generate the right `parse_align` and 
`unparse_align` string.


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