tools/pas2c/Pas2C.hs
changeset 10245 3ccc054c3c3e
parent 10240 bfae7354d42f
child 10497 c7c50f165946
equal deleted inserted replaced
10244:f7b5b4b88171 10245:3ccc054c3c3e
    13 import qualified Data.Map as Map
    13 import qualified Data.Map as Map
    14 import qualified Data.Set as Set
    14 import qualified Data.Set as Set
    15 import Data.List (find)
    15 import Data.List (find)
    16 import Numeric
    16 import Numeric
    17 
    17 
    18 import PascalParser(pascalUnit)
    18 import PascalParser
    19 import PascalUnitSyntaxTree
    19 import PascalUnitSyntaxTree
    20 
    20 
    21 
    21 
    22 data InsertOption =
    22 data InsertOption =
    23     IOInsert
    23     IOInsert
   235 pascal2C (Unit _ interface implementation _ _) =
   235 pascal2C (Unit _ interface implementation _ _) =
   236     liftM2 ($+$) (interface2C interface True) (implementation2C implementation)
   236     liftM2 ($+$) (interface2C interface True) (implementation2C implementation)
   237 
   237 
   238 pascal2C (Program _ implementation mainFunction) = do
   238 pascal2C (Program _ implementation mainFunction) = do
   239     impl <- implementation2C implementation
   239     impl <- implementation2C implementation
   240     [main] <- tvar2C True False True True (FunctionDeclaration (Identifier "main" (BTInt True)) False False False (SimpleType $ Identifier "int" (BTInt True)) [VarDeclaration False False ([Identifier "argc" (BTInt True)], SimpleType (Identifier "Integer" (BTInt True))) Nothing, VarDeclaration False False ([Identifier "argv" BTUnknown], SimpleType (Identifier "PPChar" BTUnknown)) Nothing] (Just (TypesAndVars [], mainFunction)))
   240     [main] <- tvar2C True False True True 
       
   241         (FunctionDeclaration (Identifier "main" (BTInt True)) False False False (SimpleType $ Identifier "int" (BTInt True)) 
       
   242             [VarDeclaration False False ([Identifier "argc" (BTInt True)], SimpleType (Identifier "Integer" (BTInt True))) Nothing
       
   243             , VarDeclaration False False ([Identifier "argv" BTUnknown], SimpleType (Identifier "PPChar" BTUnknown)) Nothing] 
       
   244         (Just (TypesAndVars [], Phrases [mainResultInit, mainFunction])))
   241 
   245 
   242     return $ impl $+$ main
   246     return $ impl $+$ main
   243 
   247 
   244 pascal2C _ = error "pascal2C: pattern not matched"
   248 pascal2C _ = error "pascal2C: pattern not matched"
   245 
   249