1 2 package org.jacorb.idl.runtime; 3 4 import java.util.Stack ; 5 6 21 22 public class virtual_parse_stack { 23 24 25 26 27 28 public virtual_parse_stack(Stack shadowing_stack) throws java.lang.Exception 29 { 30 31 if (shadowing_stack == null) 32 throw new Exception ( 33 "Internal parser error: attempt to create null virtual stack"); 34 35 36 real_stack = shadowing_stack; 37 vstack = new Stack (); 38 real_next = 0; 39 40 41 get_from_real(); 42 } 43 44 45 46 47 48 52 protected Stack real_stack; 53 54 55 56 60 protected int real_next; 61 62 63 64 70 protected Stack vstack; 71 72 73 74 75 76 79 protected void get_from_real() 80 { 81 symbol stack_sym; 82 83 84 if (real_next >= real_stack.size()) return; 85 86 87 stack_sym = (symbol)real_stack.elementAt(real_stack.size()-1-real_next); 88 89 90 real_next++; 91 92 93 vstack.push(new Integer (stack_sym.parse_state)); 94 } 95 96 97 98 99 public boolean empty() 100 { 101 103 return vstack.empty(); 104 } 105 106 107 108 109 public int top() throws java.lang.Exception 110 { 111 if (vstack.empty()) 112 throw new Exception ( 113 "Internal parser error: top() called on empty virtual stack"); 114 115 return ((Integer )vstack.peek()).intValue(); 116 } 117 118 119 120 121 public void pop() throws java.lang.Exception 122 { 123 if (vstack.empty()) 124 throw new Exception ( 125 "Internal parser error: pop from empty virtual stack"); 126 127 128 vstack.pop(); 129 130 131 if (vstack.empty()) 132 get_from_real(); 133 } 134 135 136 137 138 public void push(int state_num) 139 { 140 vstack.push(new Integer (state_num)); 141 } 142 143 144 145 }; 146 147 148 | Popular Tags |