Class NodeSequence

java.lang.Object
EDU.purdue.jtb.parser.syntaxtree.NodeSequence
All Implemented Interfaces:
INode, INodeList, Serializable

public class NodeSequence extends Object implements INodeList
Represents a sequence of nodes (x y z ...) nested within a choice (|), list (+), optional list (*), or optional node (? or []), e.g. ' ( A B )+ ' or ' [ C D E ] '.
The class stores the nodes list in an ArrayList.
See Also:
  • Field Details

  • Constructor Details

    • NodeSequence

      public NodeSequence()
      Initializes an empty NodeSequence with a default allocation.
    • NodeSequence

      public NodeSequence(int sz)
      Initializes an empty NodeSequence with a given allocation.
      Parameters:
      sz - - the list size
    • NodeSequence

      public NodeSequence(INode firstNode)
      Initializes an empty NodeSequence with a default allocation and adds a first node.
      Parameters:
      firstNode - - the node to add
    • NodeSequence

      public NodeSequence(int sz, INode firstNode)
      Initializes an empty NodeSequence with a given allocation and adds a first node.
      Parameters:
      sz - - the list size
      firstNode - - the node to add
  • Method Details

    • addNode

      public void addNode(INode n)
      Adds a node to the NodeSequence.
      Specified by:
      addNode in interface INodeList
      Parameters:
      n - - the node to add
    • elementAt

      public INode elementAt(int i)
      Gets the node in the list at a given position.
      Specified by:
      elementAt in interface INodeList
      Parameters:
      i - - the node's position
      Returns:
      the node
    • elements

      public Iterator<INode> elements()
      Returns an iterator on the nodes list.
      Specified by:
      elements in interface INodeList
      Returns:
      the iterator
    • size

      public int size()
      Returns the number of nodes in the list.
      Specified by:
      size in interface INodeList
      Returns:
      the list size
    • accept

      public int accept(IIntVisitor vis)
      Accepts a IIntVisitor visitor with user return data.
      Specified by:
      accept in interface INode
      Parameters:
      vis - - the visitor
      Returns:
      the user Return data
    • accept

      public void accept(IVoidVisitor vis)
      Accepts a IVoidVisitor visitor} visitor with user return data.
      Specified by:
      accept in interface INode
      Parameters:
      vis - - the visitor