mbeckerle commented on a change in pull request #88: Daffodil 1919 separators
URL: https://github.com/apache/incubator-daffodil/pull/88#discussion_r206557504
 
 

 ##########
 File path: 
daffodil-core/src/main/scala/org/apache/daffodil/grammar/LocalElementGrammarMixin.scala
 ##########
 @@ -16,206 +16,190 @@
  */
 
 package org.apache.daffodil.grammar
-import org.apache.daffodil.schema.annotation.props._
-import org.apache.daffodil.schema.annotation.props.gen._
 import org.apache.daffodil.dsom.ElementBase
-import org.apache.daffodil.equality._; object ENoWarn2 { 
EqualitySuppressUnusedImportWarning() }
-import org.apache.daffodil.grammar.primitives.StopValue
-import org.apache.daffodil.grammar.primitives.NotStopValue
-import org.apache.daffodil.grammar.primitives.RepUnbounded
-import org.apache.daffodil.grammar.primitives.RepExactlyTotalOccursCount
-import org.apache.daffodil.grammar.primitives.RepExactlyTotalN
-import org.apache.daffodil.grammar.primitives.RepExactlyN
-import org.apache.daffodil.grammar.primitives.RepAtMostTotalN
-import org.apache.daffodil.grammar.primitives.RepAtMostOccursCount
-import org.apache.daffodil.grammar.primitives.OccursCountExpression
-import org.apache.daffodil.grammar.primitives.OptionalCombinator
-import org.apache.daffodil.grammar.primitives.ArrayCombinator
 
 trait LocalElementGrammarMixin extends GrammarMixin { self: ElementBase =>
 
-  override lazy val termContentBody = prod("termContentBody") { // override in 
ElementRef
-    (if (isScalar) enclosedElement else recurrance)
-  }
-
-  protected final lazy val allowedValue = prod("allowedValue") { notStopValue 
| value }
-
-  private lazy val notStopValue = prod("notStopValue", hasStopValue) { 
NotStopValue(this) }
-
-  private lazy val separatedEmpty = prod("separatedEmpty",
-    emptyIsAnObservableConcept && !isScalar) {
-      separatedForArrayPosition(empty)
-    }
-
-  private lazy val separatedRecurringDefaultable = 
prod("separatedRecurringDefaultable", !isScalar) {
-    separatedForArrayPosition(enclosedElement)
-  }
-
-  private lazy val separatedRecurringNonDefault = 
prod("separatedRecurringNonDefault", !isScalar) {
-    separatedForArrayPosition(enclosedElementNonDefault)
-  }
-
-  private lazy val nonSeparatedScalarDefaultable = 
prod("nonSeparatedScalarDefaultable", isScalar) { enclosedElement }
-
-  private lazy val recurrance = prod("recurrance", !isScalar) {
-    if (isOptional) {
-      OptionalCombinator(this, arrayContents)
-    } else {
-      ArrayCombinator(this, arrayContents)
-    }
-  }
-
-  final override lazy val asTermInChoice = prod("asTermInChoice") {
-    nonSeparatedScalarDefaultable || recurrance
-  }
-
-  /**
-   * speculate parsing forward until we get an error
-   */
-  private lazy val separatedContentWithMinUnboundedWithoutTrailingEmpties = 
prod("separatedContentWithMinUnboundedWithoutTrailingEmpties", !isScalar) {
-    RepExactlyN(self, minOccurs, separatedRecurringDefaultable) ~
-      RepUnbounded(self, separatedRecurringNonDefault) ~
-      StopValue(this)
-  }
-
-  private lazy val separatedContentWithMinAndMaxWithoutTrailingEmpties = 
prod("separatedContentWithMinAndMaxWithoutTrailingEmpties", !isScalar) {
-    RepExactlyN(self, minOccurs, separatedRecurringDefaultable) ~
-      RepAtMostTotalN(self, maxOccurs, separatedRecurringNonDefault) ~
-      StopValue(this)
-  }
-
-  private lazy val separatedContentWithMinUnbounded = 
prod("separatedContentWithMinUnbounded", !isScalar) {
-    separatedContentWithMinUnboundedWithoutTrailingEmpties // These are for 
tolerating trailing empties. Let's not tolerate them for now.
-  }
-
-  private lazy val separatedContentWithMinAndMax = 
prod("separatedContentWithMinAndMax", !isScalar) {
-    separatedContentWithMinAndMaxWithoutTrailingEmpties // These are for 
tolerating trailing empties. Let's not tolerate them for now.
-  }
-
-  private lazy val separatedContentZeroToUnbounded = 
prod("separatedContentZeroToUnbounded", !isScalar) {
-    RepUnbounded(self, separatedRecurringNonDefault) ~
-      StopValue(this)
-  }
-
-  private lazy val separatedContentAtMostNWithoutTrailingEmpties = 
prod("separatedContentAtMostNWithoutTrailingEmpties", !isScalar) {
-    RepExactlyN(self, minOccurs, separatedRecurringDefaultable) ~
-      RepAtMostTotalN(this, maxOccurs, separatedRecurringNonDefault) ~
-      StopValue(this)
-  }
-
-  // TODO: Do we have to adjust the count to take stopValue into account?
-  // Answer: No because the counts are never used when there is a stopValue 
(at least in current
-  // thinking about how occursCountKind='stopValue' works.)
-
-  private lazy val separatedContentAtMostN = prod("separatedContentAtMostN") {
-    (separatedContentAtMostNWithoutTrailingEmpties // FIXME: We don't know 
whether we can absorb trailing separators or not here.
-    // We don't know if this repeating thing is in trailing position, or in 
the middle
-    // of a sequence. There is also ambiguity if the enclosing sequence and 
this sequence
-    // have the same separator.
-    //      ~
-    //      RepAtMostTotalN(self, maxOccurs, separatedEmpty) // absorb extra 
separators, if found.
-    )
-  }
-
-  /**
-   *  parse counted number of occurrences exactly.
-   */
-  private lazy val stopValueSize = if (hasStopValue) 1 else 0
-
-  // TODO FIXME: We really want to have different productions for parsing and 
unparsing in these
-  // complex cases where there is defaulting, etc. Unparsing has many fewer 
cases, and is just not
-  // symmetric with parsing in these situations.
-  private def separatedContentExactlyN(count: Long) = 
prod("separatedContentExactlyN") {
-    if (minOccurs == maxOccurs) {
-      // fixed length case. All are defaultable. Still might have a stop value 
tho.
-      RepExactlyN(self, count, separatedRecurringDefaultable) ~
-        StopValue(this)
-    } else {
-      // variable length case. So some defaultable, some not.
-      RepExactlyN(self, minOccurs, separatedRecurringDefaultable) ~
-        RepAtMostTotalN(self, count, separatedRecurringNonDefault) ~
-        StopValue(this) ~
-        RepExactlyTotalN(self, maxOccurs + stopValueSize, separatedEmpty) // 
absorb remaining separators after stop value.
-    }
-  }
-
-  private lazy val separatedContentExactlyNComputed = 
prod("separatedContentExactlyNComputed") {
-    OccursCountExpression(this) ~
-      RepAtMostOccursCount(this, minOccurs, separatedRecurringDefaultable) ~
-      RepExactlyTotalOccursCount(this, separatedRecurringNonDefault)
-  }
-
-  // keep in mind that anything here that scans for a representation either 
knows the length it is going after, or knows what the terminating markup is, and
-  // our invariant is, that it does NOT consume that markup ever. The parser 
consumes it with appropriate grammar terminals.
-
-  private val UNB = -1 // UNBOUNDED
-  private val ZERO = 0 // ZERO
-
-  lazy val arrayContents = prod("arrayContents", !isScalar) {
-    arrayContentsNoSeparators || arrayContentsWithSeparators
-  }
-
-  private lazy val contentUnbounded = prod("contentUnbounded") {
-    RepUnbounded(self, separatedRecurringDefaultable)
-  }
+  override lazy val termContentBody = enclosedElement
 
+  //  override lazy val termContentBody = prod("termContentBody") {
 
 Review comment:
   delete commented code

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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