equal
deleted
inserted
replaced
13 case ptree of |
13 case ptree of |
14 (Left a) -> return (show a) |
14 (Left a) -> return (show a) |
15 (Right a) -> (return . render . pascal2C) a |
15 (Right a) -> (return . render . pascal2C) a |
16 |
16 |
17 pascal2C :: PascalUnit -> Doc |
17 pascal2C :: PascalUnit -> Doc |
18 pascal2C (Unit unitName interface implementation init fin) = implementation2C implementation |
18 pascal2C (Unit unitName interface implementation init fin) = |
|
19 interface2C interface |
|
20 $+$ |
|
21 implementation2C implementation |
19 |
22 |
|
23 interface2C :: Interface -> Doc |
|
24 interface2C (Interface uses tvars) = typesAndVars2C tvars |
20 |
25 |
21 implementation2C :: Implementation -> Doc |
26 implementation2C :: Implementation -> Doc |
22 implementation2C (Implementation uses tvars) = typesAndVars2C tvars |
27 implementation2C (Implementation uses tvars) = typesAndVars2C tvars |
23 |
28 |
24 |
29 |
46 text ";" |
51 text ";" |
47 where |
52 where |
48 initExpr Nothing = empty |
53 initExpr Nothing = empty |
49 initExpr (Just e) = text "=" <+> initExpr2C e |
54 initExpr (Just e) = text "=" <+> initExpr2C e |
50 |
55 |
51 initExpr2C :: InitExpression -> Doc |
56 initExpr2C :: InitExpression -> Doc |
|
57 initExpr2C (InitBinOp op expr1 expr2) = parens $ (initExpr2C expr1) <+> op2C op <+> (initExpr2C expr2) |
|
58 initExpr2C (InitNumber s) = text s |
|
59 initExpr2C (InitFloat s) = text s |
|
60 initExpr2C (InitHexNumber s) = text "0x" <> (text . map toLower $ s) |
|
61 initExpr2C (InitString s) = doubleQuotes $ text s |
|
62 initExpr2C (InitReference (Identifier i)) = text i |
|
63 |
|
64 |
52 initExpr2C _ = text "<<expression>>" |
65 initExpr2C _ = text "<<expression>>" |
53 |
66 |
54 type2C :: TypeDecl -> Doc |
67 type2C :: TypeDecl -> Doc |
55 type2C UnknownType = text "void" |
68 type2C UnknownType = text "void" |
56 type2C String = text "string" |
69 type2C String = text "string" |