mbeckerle commented on a change in pull request #88: Daffodil 1919 separators URL: https://github.com/apache/incubator-daffodil/pull/88#discussion_r206582928
########## File path: daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/SeparatedSequenceParsers.scala ########## @@ -0,0 +1,541 @@ +/* + * 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.exceptions.Assert +import org.apache.daffodil.processors._ +import org.apache.daffodil.schema.annotation.props.SeparatorSuppressionPolicy +import org.apache.daffodil.schema.annotation.props.gen.SeparatorPosition +import ArrayIndexStatus._ +import org.apache.daffodil.dpath.NodeInfo + +trait Separated { self: SequenceChildParser => + // import ArrayIndexStatus._ + + def sep: Parser + def spos: SeparatorPosition + def ssp: SeparatorSuppressionPolicy + + val childProcessors = Seq(sep, childParser) +} + +sealed trait RepeatingSeparatedPoU extends Separated { self: RepeatingChildParser => + + private lazy val shouldRemoveZLStringHexBinaryValue_ = + false && // disable this feature as many test in daffodil-core depend on NOT removing these empty strings. + isPotentiallyTrailing && + isDeclaredLastInSequence && + ( + (ssp eq SeparatorSuppressionPolicy.TrailingEmpty) || + (ssp eq SeparatorSuppressionPolicy.TrailingEmptyStrict) + ) + + /** + * Tells us if we should remove a successfully parsed zero-length string + * or hexBinary from the infoset, because it is optional, so even though + * zero length may parse successfully and return an empty string or hexbinary + * normal value, the optionality of the element wins out over the empty-string value, and + * we don't put the element into the infoset as an array child. + */ + final def shouldRemoveZLStringHexBinaryValue(ais: ArrayIndexStatus, erd: ElementRuntimeData): Boolean = { + shouldRemoveZLStringHexBinaryValue_ + } + + /** + * Only needed for separated sequences, but in order to avoid code duplication + * we use this "fat interface" approach, and have these here by default. + * + * Override in separated, hasPoU case. + */ + def isPotentiallyTrailing: Boolean + + /** + * Only needed for separated sequences, but in order to avoid code duplication + * we use this "fat interface" approach, and have these here by default. + * + * Override in separated, hasPoU case. + */ + def isDeclaredLastInSequence: Boolean Review comment: Only used in dead-code above? Also this is problematic - in the daffodil-core this is replaced by isLastDeclaredRepresentedInSequence, and that's probably the right semantics for here also. ... if we need this at all. ---------------------------------------------------------------- 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
