Methods Summary |
---|
public boolean | empty()Indicate whether the stack is empty.
/* if vstack is empty then we were unable to transfer onto it and
the whole thing is empty. */
return vstack.empty();
|
protected void | get_from_real()Transfer an element from the real to the virtual stack. This assumes
that the virtual stack is currently empty.
Symbol stack_sym;
/* don't transfer if the real stack is empty */
if (real_next >= real_stack.size()) return;
/* get a copy of the first Symbol we have not transfered */
stack_sym = (Symbol)real_stack.elementAt(real_stack.size()-1-real_next);
/* record the transfer */
real_next++;
/* put the state number from the Symbol onto the virtual stack */
vstack.push(new Integer(stack_sym.parse_state));
|
public void | pop()Pop the stack.
if (vstack.empty())
throw new Exception(
"Internal parser error: pop from empty virtual stack");
/* pop it */
vstack.pop();
/* if we are now empty transfer an element (if there is one) */
if (vstack.empty())
get_from_real();
|
public void | push(int state_num)Push a state number onto the stack.
vstack.push(new Integer(state_num));
|
public int | top()Return value on the top of the stack (without popping it).
if (vstack.empty())
throw new Exception(
"Internal parser error: top() called on empty virtual stack");
return ((Integer)vstack.peek()).intValue();
|