mbeckerle commented on a change in pull request #214: Sequences and Separators 
Refactoring and Rewrite
URL: https://github.com/apache/incubator-daffodil/pull/214#discussion_r285240206
 
 

 ##########
 File path: 
daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/SequenceChildParseResultHelper.scala
 ##########
 @@ -0,0 +1,477 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.daffodil.processors.parsers
+
+import org.apache.daffodil.processors.Success
+import org.apache.daffodil.util.Maybe
+import org.apache.daffodil.exceptions.Assert
+import org.apache.daffodil.dpath.NodeInfo
+import org.apache.daffodil.schema.annotation.props.EmptyElementPolicy
+import org.apache.daffodil.processors.ElementRuntimeData
+import org.apache.daffodil.processors.ModelGroupRuntimeData
+import org.apache.daffodil.processors.Failure
+import org.apache.daffodil.infoset.DIElement
+import org.apache.daffodil.infoset.DISimple
+import org.apache.daffodil.infoset.DIComplex
+
+sealed abstract class PotentiallyTrailingStatus
+object PotentiallyTrailingStatus {
+  case object IsPotentiallyTrailing extends PotentiallyTrailingStatus
+  case object NotPotentiallyTrailing extends PotentiallyTrailingStatus
+}
+
+/**
+ * These helpers convert a parse state into an appropriate
+ * ParseAttemptStatus that can be acted upon uniformly by the
+ * loops iterating through sequence children parsers.
+ *
+ * The schema compiler can make many decisions statically, and supply
+ * a helper which takes a minimum of runtime overhead to make the actual
+ * decisions about whether data for example, should be considered emptyRep
+ * or absentRep based on static characteristics of the item (element, group)
+ * and the required/optionality of the item.
+ */
+trait SequenceChildParseResultHelper
+  extends Serializable {
+
+  /**
+   * Based on position within the group, is there a specific required/optional 
status
+   * that always holds.
+   *
+   * This is about position in the group, and not the ability of the 
element/model-group
+   * to have zero-length representation.
+   *
+   * Defined for non-repeating sequence children (groups, scalar elements) and 
always
+   * Required for them.
+   *
+   * Undefined for repeating sequence children.
+   */
+  def maybeStaticRequiredOptionalStatus: Maybe[RequiredOptionalStatus]
+
+  /**
+   * Compute the ParseAttemptStatus, given the state of the parse immediately 
after parsing
+   * the item (which could be group or element).
+   */
+  def computeParseAttemptStatus(parser: SequenceChildParser,
+    prevBitPosBeforeChild: Long,
+    pstate: PState,
+    requiredOptional: RequiredOptionalStatus): ParseAttemptStatus
+
 
 Review comment:
   Add scaladoc:  discuss the concept of zero-length failure, which really is a 
concept in separated formats where we can have AbsentRep and ultimately move 
past a separator even though the parse attempt failed for the child. 

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to