Make Show Type produce occam-looking types, for nicer error messages

This commit is contained in:
Adam Sampson 2007-05-16 21:15:05 +00:00
parent b6537890e0
commit 5c0a152320
2 changed files with 24 additions and 3 deletions

View File

@ -49,7 +49,30 @@ data Type =
| Any
| Timer
| Port Type
deriving (Show, Eq, Typeable, Data)
deriving (Eq, Typeable, Data)
instance Show Type where
show Bool = "BOOL"
show Byte = "BYTE"
show Int = "INT"
show Int16 = "INT16"
show Int32 = "INT32"
show Int64 = "INT64"
show Real32 = "REAL32"
show Real64 = "REAL64"
show (Array ds t)
= concat [case d of
Dimension n -> "[" ++ show n ++ "]"
UnknownDimension -> "[]"
| d <- ds] ++ show t
show (UserDataType n) = nameName n ++ "{data type}"
show (Record n) = nameName n ++ "{record}"
show (UserProtocol n) = nameName n ++ "{protocol}"
show (Chan t) = "CHAN OF " ++ show t
show (Counted ct et) = show ct ++ "::" ++ show et
show Any = "ANY"
show Timer = "TIMER"
show (Port t) = "PORT OF " ++ show t
data Dimension =
Dimension Int

View File

@ -10,8 +10,6 @@ that takes several expressions.
(Multi-subscript expressions like a[x][y] currently get pulled up into an array
slice, which is inefficient.)
The show instance for types should produce occam-looking types.
ParseState should be called something more sensible, since most of it has
nothing to do with parsing.