1 package antlr.collections;
2
3 import antlr.collections.Stack;
4 import antlr.collections.impl.LList;
5 import java.util.Enumeration;
6
7 public class LLStackTest {
8
9
10 public static void main(String[] args) {
11 LList list = new LList();
13 Stack s = list;
14 s.push(new Integer(3));
15 s.push(new Integer(4));
16 s.push(new Integer(5));
17
18 if ( s.height()!=3 )
20 System.out.println("incorrect height");
21 else
22 System.out.println("correct: height is 3");
23
24 Enumeration e = list.elements();
27 for (; e.hasMoreElements();) {
28 System.out.println(e.nextElement());
29 }
30
31 int a = ((Integer)s.pop()).intValue();
33 int b = ((Integer)s.pop()).intValue();
34 s.push( new Integer(a+b) );
35 a = ((Integer)s.pop()).intValue();
36 b = ((Integer)s.pop()).intValue();
37 int result = a * b;
38 System.out.println("result, " + result + ", should be 27");
39
40 if ( s.height()!=0 ) System.out.println("incorrect stack height");
41
42 * is a limited perspective on a LLStack implementation.
44 * Stack s2 = s;
45 * s2.includes("Frank");
46 */
47 }
48 }
49