package tcra.exercises.resolve_bounded_stack_private;

import java.util.List;
import tcra.math.Assertion;
import tcra.math.MathFormatException;
import tcra.math.MathIntegerParser;
import tcra.math.MathString;
import tcra.math.MathStringParser;
import tcra.math.MathType;

public class ResolveBoundedStack_PostClearAssertion implements
      Assertion
{
   protected MathString<MathType> empty;

   public ResolveBoundedStack_PostClearAssertion()
   {
      MathStringParser msp = new MathStringParser(
                             new MathIntegerParser());
      try { empty = msp.parse(new StringBuilder("<>")); }
      catch(MathFormatException mfe){/* Shouldn't happen */}
   } // end ctor

   @SuppressWarnings("unchecked")
   public boolean check(List<MathType> t)
   {
      MathString<MathType> self = (MathString<MathType>)t.get(1);
      if(!empty.equals(self)) return false;
      
      return true;
   } // end check(List)

   public String toString()
   {
      return("<html>S = &lt;&gt;");
   } // end toString()
   
   @SuppressWarnings("unchecked")
   public String toInstanceString(List<MathType> t)
   {
      MathString<MathType> self = (MathString<MathType>)t.get(1);
      
      return("<html>" + self.toHTMLString() + " = &lt;&gt;");
   } // end toInstanceString(List)

}
