Lines Matching refs:stack

33  *  parsers act by shifting input onto a parse stack until the Symbols
35 * stack. Once this occurs, a reduce is performed. This involves removing
43 * on top of the parse stack (stored as part of a Symbol object representing
48 * onto the stack. When the parser reduces, it pops the handle (right hand
49 * side of a production) off the stack. This leaves the parser in the state
54 * (also containing the new state) onto the stack.<p>
93 * pushed onto the stack for the reduce.
191 * is on top of the stack) and the given terminal is next on the input.
213 * the stack. The new top of stack indicates a state. This table is
264 /** Indication of the index for top of stack (for use by actions). */
274 /** The parse stack itself. */
275 protected Stack stack = new Stack();
319 * @param stack the parse stack of that object.
320 * @param top the index of the top element of the parse stack.
325 Stack stack,
538 /* the Symbol/stack element returned by a reduce */
560 stack.removeAllElements();
561 stack.push(new Symbol(0, start_state()));
571 /* current state is always on the top of the stack */
574 act = get_action(((Symbol)stack.peek()).parse_state, cur_token.sym);
579 /* shift to the encoded state by pushing it on the stack */
582 stack.push(cur_token);
592 lhs_sym = do_action((-act)-1, this, stack, tos);
598 /* pop the handle off the stack */
601 stack.pop();
606 act = get_reduce(((Symbol)stack.peek()).parse_state, lhs_sym_num);
611 stack.push(lhs_sym);
629 lhs_sym = (Symbol)stack.peek();
650 /** Dump the parse stack for debugging purposes. */
653 if (stack == null)
655 debug_message("# Stack dump requested, but stack is null");
661 /* dump the stack */
662 for (int i=0; i<stack.size(); i++)
664 debug_message("Symbol: " + ((Symbol)stack.elementAt(i)).sym +
665 " State: " + ((Symbol)stack.elementAt(i)).parse_state);
688 * @param shift_tkn the Symbol being shifted onto the stack.
698 /** Do debug output for stack state. [CSA]
702 for (int i=0; i<stack.size(); i++) {
703 Symbol s = (Symbol) stack.elementAt(i);
705 if ((i%3)==2 || (i==(stack.size()-1))) {
725 /* the Symbol/stack element returned by a reduce */
750 stack.removeAllElements();
751 stack.push(new Symbol(0, start_state()));
761 /* current state is always on the top of the stack */
765 act = get_action(((Symbol)stack.peek()).parse_state, cur_token.sym);
770 /* shift to the encoded state by pushing it on the stack */
774 stack.push(cur_token);
785 lhs_sym = do_action((-act)-1, this, stack, tos);
793 /* pop the handle off the stack */
796 stack.pop();
801 act = get_reduce(((Symbol)stack.peek()).parse_state, lhs_sym_num);
803 ((Symbol)stack.peek()).parse_state +
809 stack.push(lhs_sym);
829 lhs_sym = (Symbol)stack.peek();
842 * pop the parse stack down to a point at which we have a shift out
867 /* first pop the stack back into a state that can shift on error and
914 * state currently on the top of the (real) parse stack.
919 return get_action(((Symbol)stack.peek()).parse_state, error_sym()) > 0;
924 /** Put the (real) parse stack into error recovery configuration by
925 * popping the stack down to a state that can shift on the special
927 * the stack we return false
936 if (debug) debug_message("# Finding recovery state on stack");
938 /* Remember the right-position of the top symbol on the stack */
939 int right_pos = ((Symbol)stack.peek()).right;
940 int left_pos = ((Symbol)stack.peek()).left;
945 /* pop the stack */
947 debug_message("# Pop stack by one, state was # " +
948 ((Symbol)stack.peek()).parse_state);
949 left_pos = ((Symbol)stack.pop()).left;
953 if (stack.empty())
955 if (debug) debug_message("# No recovery state found on stack");
960 /* state on top of the stack can shift under error, find the shift */
961 act = get_action(((Symbol)stack.peek()).parse_state, error_sym());
965 ((Symbol)stack.peek()).parse_state + ")");
973 stack.push(error_token);
1049 * stack configuration using stored lookahead input and a virtual parse
1050 * stack. Return true if we make it all the way through the stored
1063 /* create a virtual stack from the real parse stack */
1064 virtual_parse_stack vstack = new virtual_parse_stack(stack);
1069 /* look up the action from the current state (on top of stack) */
1078 /* push the new state on the stack */
1101 /* pop handle off the stack */
1109 /* look up goto and push it onto the stack */
1134 /* the Symbol/stack element returned by a reduce */
1148 ((Symbol)stack.peek()).parse_state);
1154 /* current state is always on the top of the stack */
1158 get_action(((Symbol)stack.peek()).parse_state, cur_err_token().sym);
1163 /* shift to the encoded state by pushing it on the stack */
1167 stack.push(cur_err_token());
1192 lhs_sym = do_action((-act)-1, this, stack, tos);
1200 /* pop the handle off the stack */
1203 stack.pop();
1208 act = get_reduce(((Symbol)stack.peek()).parse_state, lhs_sym_num);
1213 stack.push(lhs_sym);