equal
deleted
inserted
replaced
98 data BaseType = BTUnknown |
98 data BaseType = BTUnknown |
99 | BTChar |
99 | BTChar |
100 | BTString |
100 | BTString |
101 | BTInt |
101 | BTInt |
102 | BTBool |
102 | BTBool |
|
103 | BTFloat |
103 | BTRecord [(String, BaseType)] |
104 | BTRecord [(String, BaseType)] |
104 | BTArray BaseType BaseType |
105 | BTArray BaseType BaseType |
105 | BTFunction |
106 | BTFunction |
106 | BTPointerTo BaseType |
107 | BTPointerTo BaseType |
107 | BTSet |
108 | BTSet |
108 | BTEnum [String] |
109 | BTEnum [String] |
109 | BTVoid |
110 | BTVoid |
110 deriving Show |
111 deriving Show |
111 |
|
112 |
|
113 {-- |
|
114 type2BaseType :: TypeDecl -> BaseType |
|
115 type2BaseType st@(SimpleType (Identifier s _)) = f (map toLower s) |
|
116 where |
|
117 f "longint" = BTInt |
|
118 f "integer" = BTInt |
|
119 f "word" = BTInt |
|
120 f "pointer" = BTPointerTo BTVoid |
|
121 f _ = error $ show st |
|
122 type2BaseType (Sequence ids) = BTEnum $ map (\(Identifier i _) -> i) ids |
|
123 type2BaseType (RecordType tv mtvs) = BTRecord $ concatMap f (concat $ tv : fromMaybe [] mtvs) |
|
124 where |
|
125 f (VarDeclaration _ (ids, td) _) = map (\(Identifier i _) -> (i, type2BaseType td)) ids |
|
126 type2BaseType (PointerTo t) = BTPointerTo $ type2BaseType t |
|
127 type2BaseType a = error $ show a |
|
128 --} |
|