LicenseGNU LGPLv3
Maintainerpaul.bittner@uni-ulm.de
Safe HaskellSafe

ASTPrettyPrinter

Description

Type class for pretty printing ASTs.

Synopsis

Documentation

class Show g => ASTPrettyPrinter g where Source #

An ASTPrettyPrinter can pretty print ASTs of a certain grammar.

Methods

prettyPrint :: Monoid b => b -> (Node g a -> Int -> b) -> (Node g a -> String -> b) -> (Node g a -> b) -> AST g a -> b Source #

Pretty prints the given AST (last argument) to another type b (e.g., String). Parameters are: * the start indent (e.g., ""), * an indent generator that can generate an indent of a certain width within the context of printing a certain node (e.g., (_ i -> genIndent i)), * a function to lift strings to the output type b within the context of printing a certain node, * a function print nodes, and * the AST to print.

Instances

Instances details
ASTPrettyPrinter SimpleJavaGrammar Source # 
Instance details

Defined in SimpleJava

Methods

prettyPrint :: Monoid b => b -> (Node SimpleJavaGrammar a -> Int -> b) -> (Node SimpleJavaGrammar a -> String -> b) -> (Node SimpleJavaGrammar a -> b) -> AST SimpleJavaGrammar a -> b Source #

showCode :: (Show a, Grammar g, ASTPrettyPrinter g) => AST g a -> String Source #

Default implementation for pretty printing an AST to a String.

showCodeAs :: (Monoid b, ASTPrettyPrinter g) => b -> (Node g a -> Int -> b) -> (Node g a -> String -> b) -> (Node g a -> b) -> AST g a -> b Source #

Alias for prettyPrint.