# HG changeset patch # User unc0rr # Date 1320351386 -10800 # Node ID a3e1eb794249c039cff0df140d93164fe30d02fa # Parent 13262c6e5027840c59bf5a4ff98f4821b958067f Better 'else' part diff -r 13262c6e5027 -r a3e1eb794249 tools/pas2c.hs --- a/tools/pas2c.hs Thu Nov 03 23:12:22 2011 +0300 +++ b/tools/pas2c.hs Thu Nov 03 23:16:26 2011 +0300 @@ -32,7 +32,7 @@ phrase2C :: Phrase -> Doc phrase2C (Phrases p) = braces . nest 4 . vcat . map phrase2C $ p phrase2C (ProcCall (Identifier name) params) = text name <> parens (hsep . punctuate (char ',') . map expr2C $ params) <> semi -phrase2C (IfThenElse (expr) phrase1 mphrase2) = text "if" <> parens (expr2C expr) $$ (braces . nest 4 . phrase2C) phrase1 <+> elsePart +phrase2C (IfThenElse (expr) phrase1 mphrase2) = text "if" <> parens (expr2C expr) $$ (braces . nest 4 . phrase2C) phrase1 $+$ elsePart where elsePart | isNothing mphrase2 = empty | otherwise = text "else" $$ (braces . nest 4 . phrase2C) (fromJust mphrase2)