Skip to content

Syntax printer

syntax_printer

SyntaxPrinter dataclass

Bases: Printer, ColorPrinter

A printer for printing syntax-highlighted mlir code to a terminal.

Source code in xdsl/syntax_printer.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
class SyntaxPrinter(Printer, ColorPrinter):
    """
    A printer for printing syntax-highlighted mlir code to a terminal.
    """

    def print_ssa_value(self, value: SSAValue) -> str:
        with self.colored(Colors.BRIGHT_MAGENTA):
            return super().print_ssa_value(value)

    def print_op(self, op: Operation) -> None:
        with self.colored(Colors.RED if op in self.diagnostic.op_messages else None):
            return super().print_op(op)

print_ssa_value(value: SSAValue) -> str

Source code in xdsl/syntax_printer.py
12
13
14
def print_ssa_value(self, value: SSAValue) -> str:
    with self.colored(Colors.BRIGHT_MAGENTA):
        return super().print_ssa_value(value)

print_op(op: Operation) -> None

Source code in xdsl/syntax_printer.py
16
17
18
def print_op(self, op: Operation) -> None:
    with self.colored(Colors.RED if op in self.diagnostic.op_messages else None):
        return super().print_op(op)