SPPCompiler.SemanticAnalysis.Utils.AstPrinter module

class SPPCompiler.SemanticAnalysis.Utils.AstPrinter.AstPrinter(indent_size=4)

Bases: object

! The AstPrinter class is used to print code with indentation for brace-contained blocks. It maintains a fixed indentation size, and the current indentation level.

increase_indent()
Return type:

None

decrease_indent()
Return type:

None

format_code(code)
Return type:

str

SPPCompiler.SemanticAnalysis.Utils.AstPrinter.ast_printer_method(func)

! This function is used as a decorator to use the AstPrinter’s utility methods when printing ASTs. Certain ASTs require indentation (for pretty-printing), and this decorator handles that.

@param func The function to decorate (called “print” in the ASTs). @return The decorated function.