Skip to content

Commit

Permalink
SemType: case pretty on Fortran version
Browse files Browse the repository at this point in the history
  • Loading branch information
raehik committed Mar 20, 2023
1 parent 5184d32 commit 6672905
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions src/Language/Fortran/Analysis/SemanticTypes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,29 @@ data SemType

type Dimensions = Dims NonEmpty Int

-- TODO placeholder, not final or tested
-- should really attempt to print with kind info, and change to DOUBLE PRECISION
-- etc. for <F90. Maybe cheat, use 'recoverSemTypeTypeSpec' and print resulting
-- TypeSpec?
instance Pretty SemType where
pprint' v = \case
TInteger k -> "integer"<>pd k
TReal k -> "real"<>pd k
TComplex k -> "complex"<>pd k
TLogical k -> "logical"<>pd k
TByte k -> "byte"<>pd k
TCharacter _ _ -> "character"
TArray st dims -> pprint' v st <> pprint' v dims
TCustom str -> pprint' v (TypeCustom str)
pprint' v
| v >= Fortran90 = \case
TInteger k -> "integer"<>pd k
TReal k -> "real"<>pd k
TComplex k -> "complex"<>pd k
TLogical k -> "logical"<>pd k
TByte k -> "byte"<>pd k
TCharacter _ _ -> "character(TODO)"
TArray st dims -> pprint' v st <> pprint' v dims
TCustom str -> pprint' v (TypeCustom str)
| otherwise = \case
TInteger k -> "integer"<>ad k
TReal k -> "real"<>ad k
TComplex k -> "complex"<>ad k
TLogical k -> "logical"<>ad k
TByte k -> "byte"<>ad k
TCharacter _ _ -> "character*TODO"
TArray st dims -> pprint' v st <> pprint' v dims
TCustom str -> pprint' v (TypeCustom str)
where
pd = Pretty.parens . doc
pd = Pretty.parens . doc
ad k = doc '*' <> doc k

-- | Convert 'Dimensions' data type to its previous type synonym
-- @(Maybe [(Int, Int)])@.
Expand Down

0 comments on commit 6672905

Please sign in to comment.