Package sc.parser

Class Sequence

    • Field Detail

      • skipOnErrorSlot

        public int skipOnErrorSlot
        If set, after parsing this slot return a partial-value result when partialValues is enabled
      • skipOnErrorEndSlot

        public int skipOnErrorEndSlot
        If set with skipOnErrorParselet, stop skip on error parsing at this slot
      • minContentSlot

        public int minContentSlot
        The minimum number of slots that should be filled before considering this parselet produces content. Used for partial values parsing and to set the 'anyContent' flag
      • INVALID_TYPE_IN_CHAIN

        protected static final GenerateError INVALID_TYPE_IN_CHAIN
      • MISSING_ARRAY_VALUE

        protected static final GenerateError MISSING_ARRAY_VALUE
      • ACCEPT_ERROR

        protected static final GenerateError ACCEPT_ERROR
    • Constructor Detail

      • Sequence

        public Sequence()
      • Sequence

        public Sequence​(java.lang.String id,
                        int options)
      • Sequence

        public Sequence​(int options)
      • Sequence

        public Sequence​(java.lang.String id,
                        Parselet... toAdd)
      • Sequence

        public Sequence​(Parselet... toAdd)
      • Sequence

        public Sequence​(java.lang.String id,
                        int options,
                        Parselet... toAdd)
      • Sequence

        public Sequence​(int options,
                        Parselet... toAdd)
    • Method Detail

      • parse

        public java.lang.Object parse​(Parser parser)
        Description copied from class: Parselet
        The main parse method for the parselet. Use the supplied parser and generate a 'result' either a CharSequence or an IParseNode.
        Specified by:
        parse in class Parselet
      • getSlotSemanticValue

        protected java.lang.Object getSlotSemanticValue​(int slotIx,
                                                        ISemanticNode oldNode,
                                                        SaveRestoreCtx rctx)
        For restoring the parseNode tree onto oldNode, for this sequence figure out which child node was produced by the the given slot index
      • restore

        public java.lang.Object restore​(Parser parser,
                                        ISemanticNode oldNode,
                                        RestoreCtx rctx,
                                        boolean inherited)
        Description copied from class: Parselet
        The parselet method to re-create the parse node tree given the resulting model.
        Specified by:
        restore in class Parselet
      • saveParse

        public void saveParse​(IParseNode pn,
                              ISemanticNode oldNode,
                              SaveParseCtx sctx)
        Description copied from class: Parselet
        The parselet method to save parselet ids, offsets, string-lengths etc. The info that when augmented by a de-serialized semantic node quickly reproduces the parse-node tree and attaches it to the model
        Specified by:
        saveParse in class Parselet
      • getReparseChildNode

        protected java.lang.Object getReparseChildNode​(java.lang.Object oldParent,
                                                       int ix,
                                                       boolean forceReparse)
      • parseExtendedErrors

        public java.lang.Object parseExtendedErrors​(Parser parser,
                                                    Parselet exitParselet)
        Description copied from class: Parselet
        An optional method for parsing a repeating parselet. Used in the context when we know there are errors in the file and we know the parent parselet failed to parse the exit parselet in the current context. The parselet previous to exit parselet is called with this method. It will basically reparse itself, trying to skip over error text, making sure not to skip over the exit parselet. If we do match the exit parselet, we return the newly extended node.
        Overrides:
        parseExtendedErrors in class Parselet
        Returns:
        null if we cannot extend our value. In this case, the parent parselet just uses the value it already has for this match.
      • getChildParselet

        public Parselet getChildParselet​(java.lang.Object parseNode,
                                         int index)
        Description copied from class: NestedParselet
        Best effort at returning the parselet for a given parent parse node with the specified index into the children's array. Works well for Sequence but OrderedChoice must use the data type or context in the parse node and that's not always available
        Specified by:
        getChildParselet in class NestedParselet
      • getChildParseletForIndex

        public Parselet getChildParseletForIndex​(int index)
        Description copied from class: NestedParselet
        Like the above, but returns null when the childParselet cannot be determined solely based on the index (i.e. for any OrderedChoice)
        Specified by:
        getChildParseletForIndex in class NestedParselet
      • dataTypeMatches

        public boolean dataTypeMatches​(java.lang.Object other)
        When we are trying to determine if a given node is produced by a given parselet, we use this method. It returns true if this parselet could have produced this data type.
        Overrides:
        dataTypeMatches in class Parselet
      • elementTypeMatches

        public boolean elementTypeMatches​(java.lang.Object other)
        When we are trying to determine if a given node is produced by a given parselet, we use this method. It returns true if this parselet could have produced this data type.
        Overrides:
        elementTypeMatches in class Parselet
      • disableExtendedErrors

        protected boolean disableExtendedErrors()