License | GNU LGPLv3 |
---|---|
Maintainer | paul.bittner@uni-ulm.de |
Safe Haskell | Safe |
Type class for pretty printing AST
s.
Synopsis
- class Show g => ASTPrettyPrinter g where
- prettyPrint :: Monoid b => b -> (Node g a -> Int -> b) -> (Node g a -> String -> b) -> (Node g a -> b) -> AST g a -> b
- showCode :: (Show a, Grammar g, ASTPrettyPrinter g) => AST g 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
Documentation
class Show g => ASTPrettyPrinter g where Source #
An ASTPrettyPrinter can pretty print ASTs of a certain grammar.
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
ASTPrettyPrinter SimpleJavaGrammar Source # | |
Defined in SimpleJava 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
.