929 * @param debug should we produce debugging messages as we parse.
930 */
931 protected boolean find_recovery_config(boolean debug)
932 {
933 Symbol error_token;
934 int act;
935
936 if (debug) debug_message("# Finding recovery state on stack");
937
938 /* Remember the right-position of the top symbol on the stack */
939 int right_pos = (stack.peek()).right;
940 int left_pos = (stack.peek()).left;
941
942 /* pop down until we can shift under error Symbol */
943 while (!shift_under_error())
944 {
945 /* pop the stack */
946 if (debug)
947 debug_message("# Pop stack by one, state was # " +
948 (stack.peek()).parse_state);
949 left_pos = ((Symbol)stack.pop()).left;
950 tos--;
951
952 /* if we have hit bottom, we fail */
953 if (stack.empty())
954 {
955 if (debug) debug_message("# No recovery state found on stack");
956 return false;
957 }
958 }
959
960 /* state on top of the stack can shift under error, find the shift */
961 act = get_action((stack.peek()).parse_state, error_sym());
962 if (debug)
963 {
964 debug_message("# Recover state found (#" +
965 (stack.peek()).parse_state + ")");
966 debug_message("# Shifting on error to state #" + (act-1));
967 }
968
969 /* build and shift a special error Symbol */
|
929 * @param debug should we produce debugging messages as we parse.
930 */
931 protected boolean find_recovery_config(boolean debug)
932 {
933 Symbol error_token;
934 int act;
935
936 if (debug) debug_message("# Finding recovery state on stack");
937
938 /* Remember the right-position of the top symbol on the stack */
939 int right_pos = (stack.peek()).right;
940 int left_pos = (stack.peek()).left;
941
942 /* pop down until we can shift under error Symbol */
943 while (!shift_under_error())
944 {
945 /* pop the stack */
946 if (debug)
947 debug_message("# Pop stack by one, state was # " +
948 (stack.peek()).parse_state);
949 left_pos = stack.pop().left;
950 tos--;
951
952 /* if we have hit bottom, we fail */
953 if (stack.empty())
954 {
955 if (debug) debug_message("# No recovery state found on stack");
956 return false;
957 }
958 }
959
960 /* state on top of the stack can shift under error, find the shift */
961 act = get_action((stack.peek()).parse_state, error_sym());
962 if (debug)
963 {
964 debug_message("# Recover state found (#" +
965 (stack.peek()).parse_state + ")");
966 debug_message("# Shifting on error to state #" + (act-1));
967 }
968
969 /* build and shift a special error Symbol */
|