tools/pas2c.hs
changeset 6391 bd5851ab3157
parent 6355 734fed7aefd3
child 6399 a904c735979c
--- a/tools/pas2c.hs	Wed Nov 16 16:36:17 2011 -0500
+++ b/tools/pas2c.hs	Thu Nov 17 17:57:45 2011 +0400
@@ -15,8 +15,13 @@
          (Right a) -> (return . render . pascal2C) a
 
 pascal2C :: PascalUnit -> Doc
-pascal2C (Unit unitName interface implementation init fin) = implementation2C implementation
+pascal2C (Unit unitName interface implementation init fin) = 
+    interface2C interface
+    $+$ 
+    implementation2C implementation
 
+interface2C :: Interface -> Doc
+interface2C (Interface uses tvars) = typesAndVars2C tvars
 
 implementation2C :: Implementation -> Doc
 implementation2C (Implementation uses tvars) = typesAndVars2C tvars
@@ -48,7 +53,15 @@
     initExpr Nothing = empty
     initExpr (Just e) = text "=" <+> initExpr2C e
 
-initExpr2C :: InitExpression -> Doc    
+initExpr2C :: InitExpression -> Doc
+initExpr2C (InitBinOp op expr1 expr2) = parens $ (initExpr2C expr1) <+> op2C op <+> (initExpr2C expr2)
+initExpr2C (InitNumber s) = text s
+initExpr2C (InitFloat s) = text s
+initExpr2C (InitHexNumber s) = text "0x" <> (text . map toLower $ s)
+initExpr2C (InitString s) = doubleQuotes $ text s 
+initExpr2C (InitReference (Identifier i)) = text i
+
+
 initExpr2C _ = text "<<expression>>"
 
 type2C :: TypeDecl -> Doc