Package sc.parser

Class ParentParseNode

    • Field Detail

      • children

        public java.util.ArrayList<java.lang.Object> children
      • value

        public java.lang.Object value
    • Constructor Detail

      • ParentParseNode

        public ParentParseNode()
      • ParentParseNode

        public ParentParseNode​(Parselet p)
    • Method Detail

      • getSemanticValue

        public java.lang.Object getSemanticValue()
      • setSemanticValue

        public void setSemanticValue​(java.lang.Object val,
                                     boolean clearOld,
                                     boolean restore)
      • addForReparse

        public int addForReparse​(java.lang.Object node,
                                 Parselet p,
                                 int svIndex,
                                 int childIndex,
                                 int slotIndex,
                                 boolean skipSemanticValue,
                                 Parser parser,
                                 java.lang.Object oldChildParseNode,
                                 DiffContext dctx,
                                 boolean removeExtraNodes,
                                 boolean parseArray)
      • cullUnparsedNodes

        public void cullUnparsedNodes​(Parser parser,
                                      int svCount,
                                      int startChild,
                                      DiffContext dctx)
      • removeForReparse

        public boolean removeForReparse​(int svIndex,
                                        int childIndex,
                                        int slotIndex,
                                        boolean skipSemanticValue,
                                        Parser parser)
      • add

        public int add​(java.lang.Object node,
                       Parselet p,
                       int svIndex,
                       int index,
                       boolean skipSemanticValue,
                       Parser parser)
        Adds a child parse node to this parent node for the given child parselet. The svIndex can be used for multi-valued parselets to add the semantic-value to a specific array index for reparsing. Usually it's -1 for appending the element. The index specifies the slot index of the parselet 'p' in the parent. If skipSemanticValue is true, the parse node is added without updating the semantic value.
      • addOrSet

        public void addOrSet​(java.lang.Object node,
                             Parselet p,
                             int svIndex,
                             int index,
                             boolean skipSemanticValue,
                             Parser parser)
      • set

        public void set​(java.lang.Object node,
                        Parselet p,
                        int index,
                        boolean skipSemanticValue,
                        Parser parser)
      • addGeneratedNode

        public void addGeneratedNode​(java.lang.Object node)
      • addGeneratedNode

        public void addGeneratedNode​(java.lang.Object node,
                                     Parselet childParselet)
        Faster version when we are generating strings a char at a time
      • addGeneratedNodeAt

        public void addGeneratedNodeAt​(int ix,
                                       java.lang.Object node)
      • toString

        public java.lang.String toString()
        Specified by:
        toString in interface java.lang.CharSequence
        Overrides:
        toString in class java.lang.Object
      • formatString

        public java.lang.String formatString​(java.lang.Object parSemVal,
                                             ParentParseNode curParseNode,
                                             int curChildIndex,
                                             boolean replaceFormatting)
        Formats the parse node - turning it into a String. Parent should specify the semantic node parent of this parse node. If null is specified, it's no problem as long as this parse-node's semantic value has a parent. Some primitive parse nodes have a string semantic value with no ref to their parent. For the spacing to be computed properly we need this context (for FormatContext.getNextSemanticValue())
        Specified by:
        formatString in interface IParseNode
        Overrides:
        formatString in class AbstractParseNode
      • styleNode

        public void styleNode​(IStyleAdapter adapter,
                              java.lang.Object parSemVal,
                              ParentParseNode parNode,
                              int childIx)
        Description copied from interface: IParseNode
        Just like formatString, we need to take an optional parent semantic value, parseNode, and childIndex so we know where this element falls in the context so we can do spacing properly
        Specified by:
        styleNode in interface IParseNode
        Overrides:
        styleNode in class AbstractParseNode
      • reformat

        public IParseNode reformat()
        Description copied from interface: IParseNode
        Reformats the parse node - replacing any explicit spacing nodes with the generateParseNode in the tree. The next toString will then reformat the parse nodes
        Specified by:
        reformat in interface IParseNode
        Overrides:
        reformat in class AbstractParseNode
      • computeLineNumberForNode

        public void computeLineNumberForNode​(LineFormatContext ctx,
                                             IParseNode toFindPN)
        Description copied from interface: IParseNode
        Internal method used to walk the parse tree to find the line number for a given parse node (which must be in the tree).
      • toDebugString

        public java.lang.String toDebugString()
      • refersToSemanticValue

        public boolean refersToSemanticValue​(java.lang.Object sv)
      • firstChar

        public int firstChar()
        Description copied from interface: IParseNode
        Returns the first character value produced or -1 if there is none
      • isGenerated

        public boolean isGenerated()
      • length

        public int length()
        Description copied from interface: IParseNode
        Returns the number of characters in the parse node
        Specified by:
        length in interface java.lang.CharSequence
        Specified by:
        length in interface IParseNode
        Overrides:
        length in class AbstractParseNode
      • charAt

        public char charAt​(int ix)
        Specified by:
        charAt in interface java.lang.CharSequence
        Overrides:
        charAt in class AbstractParseNode
      • subSequence

        public java.lang.CharSequence subSequence​(int start,
                                                  int end)
        Specified by:
        subSequence in interface java.lang.CharSequence
        Overrides:
        subSequence in class AbstractParseNode
      • advanceStartIndex

        public void advanceStartIndex​(int ix)
        Description copied from interface: IParseNode
        If you take a language string and reparse it this lets you advance the start index to where it originally existed in the file (e.g. for HTML attribute expressions which are not parsed as part of the original grammar)
        Specified by:
        advanceStartIndex in interface IParseNode
        Overrides:
        advanceStartIndex in class AbstractParseNode
      • updateSemanticValue

        public void updateSemanticValue​(java.util.IdentityHashMap<java.lang.Object,​java.lang.Object> oldNewMap)
      • findParseNode

        public IParseNode findParseNode​(int startIndex,
                                        Parselet matchParselet,
                                        boolean overlap)
        Description copied from interface: IParseNode
        Find the parse node at the specified start index. If matchParselet is not null the match is only returned if it is the same as the parselet specified
        Specified by:
        findParseNode in interface IParseNode
        Overrides:
        findParseNode in class AbstractParseNode
      • isGeneratedTree

        public boolean isGeneratedTree()
        Description copied from interface: IParseNode
        Returns true if any nodes in this tree have been through the 'generate' process. These nodes might have formatting parse nodes that need to be replaced for some operations
      • resetStartIndex

        public int resetStartIndex​(int ix,
                                   boolean validate,
                                   boolean updateNewIndex)
        Description copied from interface: IParseNode
        After updating some parse nodes, you may need to reset the start indexes. This sets the start index to the one given and returns the start index to continue after this parse node.
        Specified by:
        resetStartIndex in interface IParseNode
        Overrides:
        resetStartIndex in class AbstractParseNode
      • isLastChild

        public boolean isLastChild​(int ix)
      • findStartDiff

        public void findStartDiff​(DiffContext ctx,
                                  boolean atEnd,
                                  java.lang.Object parSemVal,
                                  ParentParseNode parParseNode,
                                  int childIx)
        Description copied from interface: IParseNode
        Finds the first parse node whose text does not match the DiffContext
      • findEndDiff

        public void findEndDiff​(DiffContext ctx,
                                java.lang.Object parSemVal,
                                ParentParseNode parParseNode,
                                int childIx)
      • getNumSemanticValues

        public int getNumSemanticValues()
        Description copied from interface: IParseNode
        Used for reparse only, this method determines how many semantic value elements were produced by this parse node. Returns 1 for scalar semantic values or for a repeat value, the number of elements in the semantic value array. It's not just the size of the semantic value List because during reparse, we combine all of the elements from multiple parse nodes into one List when there's one repeat array node which has a child parselet that's also a repeat array node. Instead, we look at the number of child parse nodes and use that to determine how many array values came from the this node.
        Specified by:
        getNumSemanticValues in interface IParseNode
        Overrides:
        getNumSemanticValues in class AbstractParseNode
      • addParseErrors

        public void addParseErrors​(java.util.List<ParseError> res,
                                   int max)
        Description copied from interface: IParseNode
        For incremental parses, return the list of errors detected and continued in the parse-stream (useful for syntax highlighting)