{{ state.rules.each do |rule| }}
{{= rule }}
{{= "{" << rule.lookahead.to_a.join(", ") << "}" }}
{{ end }}
{{
transitions = v.each.select { |_, a| a && a[0] == :state }
reductions = v.each.select { |_, a| a && a[0] == :reduce}
accepting = v.each.select { |_, a| a && a[0] == :accept}
conflicts = tableizer.conflicts[i].each
thing = [:transitions, :reductions, :accepting]
num_type = {
transitions: "State",
reductions: "Rule",
accepting: "Rule"
}
h = Hash[thing.zip([transitions, reductions, accepting])]
}}
{{ h.each do |key, value| }}
{{ next unless value.any? }}
{{= key }}
{{ value.each do |token, (_, name)| }}
{{ token_value = grammar.terminals.find { |_| _.name == token } || token }}
{{= token_value}}: {{= num_type[key] }} {{= name }}
{{ end }}
{{ end }}
{{ if conflicts.any? }}
Conflicts
{{ conflicts.each do |token, (value, first, second, rule, terminal)| }}
{{= token }}: {{= first.join(" ") }}/{{= second.join(" ") }} ({{= rule }} vs {{= terminal }})
{{ end }}
{{ end }}