You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by GitBox <gi...@apache.org> on 2020/05/27 04:10:04 UTC

[GitHub] [incubator-daffodil] stevedlawrence commented on a change in pull request #385: Fix initiatedContent="yes" with empty initiator

stevedlawrence commented on a change in pull request #385:
URL: https://github.com/apache/incubator-daffodil/pull/385#discussion_r430353555



##########
File path: daffodil-runtime1/src/main/scala/org/apache/daffodil/dsom/CompiledExpression1.scala
##########
@@ -143,7 +143,7 @@ final case class ConstantExpression[+T <: AnyRef](
 
   lazy val sourceType: NodeInfo.Kind = NodeInfo.fromObject(value)
 
-  def isKnownNonEmpty = value != ""
+  def isKnownNonEmpty = value != "" && value != "%ES;" && !(value == "%WSP*;" && qn.toQNameString == "dfdl:initiator")

Review comment:
       I'm not sure this is the correct fix. Looking at ``InitatedTerminatedMixin.scala``, one place where ``isKnownNonEmpty`` is used, ``hasInitiator`` and ``hasTerminator`` look like this:
   ```scala
   /**
    * True if the term has an initiator expressed on it.
    *
    * Do not confuse with the concept of the delimiter being able to match or
    * not match zero-length data. Whether the representation of a term in the
    * data stream "has an initiator", as in the initator occupies a non-zero
    * number of bits in the data stream, is an entirely different question.
    */
     lazy val hasInitiator = {
       val hasOne = initiatorExpr.isKnownNonEmpty
       hasOne
     }
   ```
   Based on that comment, it think ``isKnownNonEmpty`` should only ever return true if the value is an empty string.
   
   I'm not sure of the right fix though. Maybe the EvDelimiters or DFADelimiter needs special logic to determine if a compiled DFADelimiter can match an empty string?
   
   Note that Delimiters can be something like ``%WSP*;%WSP*;``. It's non sensical,  but I dont' think the above check would chatch that. We do have logic in the DFA compiler to reduce things like this (in DFDLDelimiter.scala) so detecting if a delimiter could match empty string might not be too bad? Just need to check if it compiles to a single Delimiter that is either ESDelim or WSPStarDelim?




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org