Class ParseNode


  • public abstract class ParseNode
    extends Object
    Class used by the JavaCUP parser to construct a parse tree.
    • Constructor Detail

      • ParseNode

        protected ParseNode​(int tag,
                            String file,
                            int line,
                            int column)
        generic constructor
        Parameters:
        tag - identifies the type of this node
        file - identifies the file containing the node's text
        line - identifies the start line for this node's text
        column - identifies the start columen for this node's text
    • Method Detail

      • getTag

        public int getTag()
        get the tag for this node
        Returns:
        the tag for this node
      • getLine

        public int getLine()
        get the line position for this node
        Returns:
        the line position for this node
      • getColumn

        public int getColumn()
        get the column position for this node
        Returns:
        the column position for this node
      • getChildCount

        public abstract int getChildCount()
        get the child count for this node
        Returns:
        the child count for this node
      • getChild

        public abstract Object getChild​(int idx)
        get the nth child for this node or null if the index exceeds the child count
        Parameters:
        idx - the child index
        Returns:
        the nth child for this node
      • getText

        public abstract String getText()
        get the display representation of this node
        Returns:
        the display representation of this node
      • getPos

        public String getPos()
        get a string representing the position for this node
        Returns:
        a string representing the position for this node
      • node

        public static ParseNode node​(int tag,
                                     String file,
                                     int line,
                                     int column)
        create a simple node for a builtin token
        Parameters:
        tag - identifies the type of this node
        file - identifies the file containing the node's text
        line - identifies the start line for this node's text
        column - identifies the start columen for this node's text
        Returns:
        a simple node for a builtin token
      • node

        public static ParseNode node​(int tag,
                                     String file,
                                     int line,
                                     int column,
                                     Object child0)
        create a simple node for a builtin token
        Parameters:
        tag - identifies the type of this node
        file - identifies the file containing the node's text
        line - identifies the start line for this node's text
        column - identifies the start columen for this node's text
        child0 - the first child for this node
        Returns:
        a simple node for a builtin token
      • node

        public static ParseNode node​(int tag,
                                     String file,
                                     int line,
                                     int column,
                                     Object child0,
                                     Object child1)
        create a simple node for a builtin token
        Parameters:
        tag - identifies the type of this node
        file - identifies the file containing the node's text
        line - identifies the start line for this node's text
        column - identifies the start columen for this node's text
        child0 - the first child for this node
        child1 - the second child for this node
        Returns:
        a simple node for a builtin token
      • node

        public static ParseNode node​(int tag,
                                     String file,
                                     int line,
                                     int column,
                                     Object child0,
                                     Object child1,
                                     Object child2)
        create a simple node for a builtin token
        Parameters:
        tag - identifies the type of this node
        file - identifies the file containing the node's text
        line - identifies the start line for this node's text
        column - identifies the start columen for this node's text
        child0 - the first child for this node
        child1 - the second child for this node
        child2 - the third child for this node
        Returns:
        a simple node for a builtin token
      • node

        public static ParseNode node​(int tag,
                                     String file,
                                     int line,
                                     int column,
                                     Object child0,
                                     Object child1,
                                     Object child2,
                                     Object child3)
        create a simple node for a builtin token
        Parameters:
        tag - identifies the type of this node
        file - identifies the file containing the node's text
        line - identifies the start line for this node's text
        column - identifies the start columen for this node's text
        child0 - the first child for this node
        child1 - the second child for this node
        child2 - the third child for this node
        child3 - the fourth child for this node
        Returns:
        a simple node for a builtin token