language-lua-0.9.0: Lua parser and pretty-printer

Safe HaskellSafe
LanguageHaskell2010

Language.Lua.PrettyPrinter

Description

Lua pretty-printer.

Synopsis

Documentation

pprint :: LPretty a => a -> Doc Source #

renderPretty :: Float -> Int -> Doc -> SimpleDoc Source #

This is the default pretty printer which is used by show, putDoc and hPutDoc. (renderPretty ribbonfrac width x) renders document x with a page width of width and a ribbon width of (ribbonfrac * width) characters. The ribbon width is the maximal amount of non-indentation characters on a line. The parameter ribbonfrac should be between 0.0 and 1.0. If it is lower or higher, the ribbon width will be 0 or width respectively.

displayS :: SimpleDoc -> ShowS Source #

(displayS simpleDoc) takes the output simpleDoc from a rendering function and transforms it to a ShowS type (for use in the Show class).

showWidth :: Int -> Doc -> String
showWidth w x   = displayS (renderPretty 0.4 w x) ""

displayIO :: Handle -> SimpleDoc -> IO () Source #

(displayIO handle simpleDoc) writes simpleDoc to the file handle handle. This function is used for example by hPutDoc:

hPutDoc handle doc  = displayIO handle (renderPretty 0.4 100 doc)

class LPretty a where Source #

Methods

pprint :: a -> Doc Source #

Instances

LPretty Bool Source # 

Methods

pprint :: Bool -> Doc Source #

pprint' :: Precedence -> Bool -> Doc

LPretty FunArg Source # 

Methods

pprint :: FunArg -> Doc Source #

pprint' :: Precedence -> FunArg -> Doc

LPretty FunCall Source # 

Methods

pprint :: FunCall -> Doc Source #

pprint' :: Precedence -> FunCall -> Doc

LPretty FunBody Source # 

Methods

pprint :: FunBody -> Doc Source #

pprint' :: Precedence -> FunBody -> Doc

LPretty FunName Source # 

Methods

pprint :: FunName -> Doc Source #

pprint' :: Precedence -> FunName -> Doc

LPretty Block Source # 

Methods

pprint :: Block -> Doc Source #

pprint' :: Precedence -> Block -> Doc

LPretty TableField Source # 

Methods

pprint :: TableField -> Doc Source #

pprint' :: Precedence -> TableField -> Doc

LPretty PrefixExp Source # 

Methods

pprint :: PrefixExp -> Doc Source #

pprint' :: Precedence -> PrefixExp -> Doc

LPretty Unop Source # 

Methods

pprint :: Unop -> Doc Source #

pprint' :: Precedence -> Unop -> Doc

LPretty Binop Source # 

Methods

pprint :: Binop -> Doc Source #

pprint' :: Precedence -> Binop -> Doc

LPretty Var Source # 

Methods

pprint :: Var -> Doc Source #

pprint' :: Precedence -> Var -> Doc

LPretty Exp Source # 

Methods

pprint :: Exp -> Doc Source #

pprint' :: Precedence -> Exp -> Doc

LPretty Stat Source # 

Methods

pprint :: Stat -> Doc Source #

pprint' :: Precedence -> Stat -> Doc

LPretty Name Source # 

Methods

pprint :: Name -> Doc Source #

pprint' :: Precedence -> Name -> Doc

LPretty [Char] Source # 

Methods

pprint :: [Char] -> Doc Source #

pprint' :: Precedence -> [Char] -> Doc

LPretty [TableField] Source # 

Methods

pprint :: [TableField] -> Doc Source #

pprint' :: Precedence -> [TableField] -> Doc