public bool FindErrorRecoveryState() { while (true) // pop states until one found that accepts error token { if (current_state.parser_table != null) { int errt; if (current_state.parser_table.TryGetValue(errToken, out errt) && errt > 0) // shift { return(true); } } state_stack.Pop(); value_stack.Pop(); location_stack.Pop(); if (state_stack.IsEmpty()) { return(false); } else { current_state = state_stack.Top(); } } }
public bool FindErrorRecoveryState() { while (true) // pop states until one found that accepts error token { if (current_state.parser_table != null && current_state.parser_table.ContainsKey(errToken) && current_state.parser_table[errToken] > 0) // shift { return(true); } if (Trace) { Console.Error.WriteLine("Error: popping state {0}", state_stack.Top().num); } //System.Diagnostics.Trace.WriteLine( // String.Format("Error: popping state {0}", state_stack.Top().num)); state_stack.Pop(); value_stack.Pop(); location_stack.Pop(); if (Trace) { DisplayStack(); } if (state_stack.IsEmpty()) { if (Trace) { Console.Error.Write("Aborting: didn't find a state that accepts error token"); } //System.Diagnostics.Trace.WriteLine("Aborting: didn't find a state that accepts error token"); return(false); } else { current_state = state_stack.Top(); } } }