108 def stringify_state(self, state_id):
109 state_title = 'State %d\n' % state_id
110
111 items = drop_itemset_lookaheads(kernels(self.__ccol[state_id]))
112 items = sorted(items, key=lambda elem: elem[0])
113
114 items_str = '\n'.join('\t' + self.__stringify_lr_zero_item(item) for item in items) + '\n\n'
115
116 actions = [(t, e) for t, e in self.action[state_id].items() if len(e) > 0]
117 actions = sorted(actions, key=lambda elem: elem[0])
118
119 actions_str = '\n'.join(self.__stringify_action_entries(t, e) for t, e in actions)
120 actions_str += ('\n' if len(actions_str) > 0 else '')
121
122 gotos = [(nt, sid) for nt, sid in self.goto[state_id].items() if sid is not None]
123 gotos = sorted(gotos, key=lambda elem: elem[0].name)
124
125 gotos_str = '\n'.join(self.__stringify_goto_entry(nt, sid) for nt, sid in gotos)
126 gotos_str += ('\n' if len(gotos_str) > 0 else '')
127
128 action_goto_separator = ('\n' if len(actions_str) > 0 and len(gotos_str) > 0 else '')
129
130 return state_title + items_str + actions_str + action_goto_separator + gotos_str
131