import io import parser def generate_rust_parser(output: io.TextIOBase, table: list[dict[str, parser.Action]]): lines = [] tree_kinds = list( sorted( { action[1] for state in table for action in state.values() if action[0] == "reduce" and action[1][0] != "_" } ) ) # First, generate the treekind enumeration lines.extend( [ "#[derive(Debug, Eq, PartialEq)]", "pub enum TreeKind {", " Error,", "", ] ) lines.extend(f" {kind}," for kind in tree_kinds) lines.extend( [ "}", "", ] ) # Next generate the parse table lines.extend([]) pass