Class SyntaxTree

  • All Implemented Interfaces:
    java.lang.Iterable<SyntaxTree>

    public class SyntaxTree
    extends java.lang.Object
    implements java.lang.Iterable<SyntaxTree>
    A syntax tree corresponding to an expression.
    Author:
    Curtis Rueden
    • Constructor Summary

      Constructors 
      Constructor Description
      SyntaxTree​(java.util.LinkedList<java.lang.Object> tokens)
      Creates a syntax tree built from the given postfix token queue.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      SyntaxTree child​(int index)  
      int count()  
      boolean equals​(java.lang.Object o)  
      int hashCode()  
      java.util.Iterator<SyntaxTree> iterator()  
      java.util.LinkedList<java.lang.Object> postfix()
      Converts the syntax tree into a token queue in postfix order.
      java.lang.Object token()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • SyntaxTree

        public SyntaxTree​(java.util.LinkedList<java.lang.Object> tokens)
        Creates a syntax tree built from the given postfix token queue. This process will consume the entire queue.
        Parameters:
        tokens - The token queue, in postfix order.
    • Method Detail

      • token

        public java.lang.Object token()
      • count

        public int count()
      • postfix

        public java.util.LinkedList<java.lang.Object> postfix()
        Converts the syntax tree into a token queue in postfix order.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • iterator

        public java.util.Iterator<SyntaxTree> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<SyntaxTree>