stevedlawrence opened a new pull request, #1533: URL: https://github.com/apache/daffodil/pull/1533
> [!NOTE] > This is an alternate approach to PR #1504. I started adding assertions as suggested in that PR but many of them actually failed and couldn't be easily fixed. I realized that our logic to set elements as final was actually pretty broken and we just got lucky that things were mostly working. This required reworking the solution, but I think this is now easier to make sense of when things are marked as final and allows all the invariants to hold. Our current logic to handle setting elements as final during parse is pretty broken. The core issue is that we primarily call setFinal in the sequence parser where it is difficult to know which elements are actually final--we had to make assumptions based on the results of the things actualy parsing elements. This usually worked, but in some cases could lead to setting an element final multiple times, or setting an element as final when it wasn't actually final. A case where this flawed logic could lead to issues is with InfosetInputters that aren't designed to receive invalid infosets, such as JDOM or SAX inputters. Note that InfosetInputters aren't required to handle invalid infosets, except for those that are used by the debugger. This could lead to incomplete error diagnostics or misleading reasons for an error. To make the final logic more clear and avoid these kinds of errors, DINode.isFinal is made private with new getFinal and setFinal method used instead. These functions allow us to place a number of assertions throughout the infoset logic to ensure we set things as final appropriately. This also moves where we set elements as final. DISimple and DIComplex elements are set final in the ElementCombinatorParser and only when they successfully parse. This avoids cases where an element could be set final even though it failed to parse and removes any ambiguities about what sholud be set final. DIArrays are set final in the sequence parser that handles the ending of arrays, with special logic to handle arrays in unordered sequences. Note that the sequence parser is still responsible for attempting to walk the infoset to project the internal infoset into the target infoset--keeping all the walk logic in one place. DAFFODIL-3006 -- 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]
