2014-01-04 09:14:36 +00:00
|
|
|
{-# OPTIONS_GHC -Wall #-}
|
2013-06-14 01:00:24 +00:00
|
|
|
module SourceSyntax.Literal where
|
|
|
|
|
2013-07-07 10:56:34 +00:00
|
|
|
import SourceSyntax.PrettyPrint
|
|
|
|
import qualified Text.PrettyPrint as PP
|
2013-06-14 01:00:24 +00:00
|
|
|
|
|
|
|
data Literal = IntNum Int
|
2013-08-31 20:14:39 +00:00
|
|
|
| FloatNum Double
|
2013-06-14 01:00:24 +00:00
|
|
|
| Chr Char
|
|
|
|
| Str String
|
|
|
|
| Boolean Bool
|
2013-12-29 21:18:40 +00:00
|
|
|
deriving (Eq, Ord, Show)
|
2013-06-14 01:00:24 +00:00
|
|
|
|
2013-07-07 10:56:34 +00:00
|
|
|
instance Pretty Literal where
|
|
|
|
pretty literal =
|
|
|
|
case literal of
|
|
|
|
IntNum n -> PP.int n
|
2013-08-31 20:14:39 +00:00
|
|
|
FloatNum n -> PP.double n
|
2014-01-07 21:52:19 +00:00
|
|
|
Chr c -> PP.text . show $ c
|
|
|
|
Str s -> PP.text . show $ s
|
2013-12-29 21:18:40 +00:00
|
|
|
Boolean bool -> PP.text (show bool)
|