Class ParsingMap

    • Constructor Detail

      • ParsingMap

        public ParsingMap()
    • Method Detail

      • startMark

        public void startMark()
      • startMark

        public void startMark​(boolean clearAdded)
      • endMark

        public void endMark()
      • rollback

        public void rollback()
      • clearMark

        public void clearMark()
      • getElements

        public ArrayList<Element> getElements()
        At the end of parsing, this has all of the executable elements in it. Get this, grab the included statement(it's just a wrapper class) and you are off.
        Returns:
      • setAddedIds

        public void setAddedIds​(List<String> addedIds)
      • getStatementFromContext

        public Statement getStatementFromContext​(org.antlr.v4.runtime.tree.ParseTree context)
      • findAncestor

        public ParseRecord findAncestor​(org.antlr.v4.runtime.tree.ParseTree parseTree)
        Find the parent or grandparent etc. of the node in this map. A common pattern is, e.g. having a heavily parenthesized expression in the source like

        (((a<b) &&...

        which may have arbitrarily many association contexts wrapped around it. Our creation of the standard tree omits such parsing cruft so this will trace back to the ancestor.
        Parameters:
        parseTree -
        Returns:
      • nukeIt

        public void nukeIt​(org.antlr.v4.runtime.tree.ParseTree parseTree)
        This will find all the child nodes in this map and remove the entire tree. This is useful if, for instance you have defined a bunch of statements in a function definition or some such.
        Parameters:
        parseTree -
      • findFirstChild

        public ParseRecord findFirstChild​(org.antlr.v4.runtime.tree.ParseTree parseTree)
        In this case we have the id of a node that is not in this map because there are many types of intermediate node created by the parser we just don't record. This will take an id then look at the parent child relations and return the first child it finds in this map. E.g.,
             A → B → C → D
         
        In this case, A is in the map, B and C are artifacts of parsing that are not in the map and we need D. So we take the ParseTree for A, look at the childen for B and continue until D is found. Use this sparingly since it may end up snooping through a lot of nodes, however, this is about the best option for finding this.
        Parameters:
        parseTree -
        Returns:
      • findFirstChild

        public ParseRecord findFirstChild​(org.antlr.v4.runtime.tree.ParseTree parseTree,
                                          boolean returnNullOK)
      • getKids

        protected List<org.antlr.v4.runtime.tree.ParseTree> getKids​(org.antlr.v4.runtime.tree.ParseTree parseTree)