on e123780 help sign in
43 lines 1.1 kB history raw
1{-# OPTIONS_GHC -Wall #-}
2module SourceSyntax.Literal where
4import Data.Map (Map)
5import SourceSyntax.PrettyPrint
6import qualified Text.PrettyPrint as PP
8data Literal = IntNum Int
9 | FloatNum Double
10 | Chr Char
11 | Str String
12 | Boolean Bool
13 deriving (Eq, Ord, Show)
15instance Pretty Literal where
16 pretty literal =
17 case literal of
18 IntNum n -> PP.int n
19 FloatNum n -> PP.double n
20 Chr c -> PP.text . show $ c
21 Str s -> PP.text . show $ s
22 Boolean bool -> PP.text (show bool)
24data GLTipe = Int | Float | V2 | V3 | V4 | M4 | Texture
25 deriving (Show)
27glTipeName :: GLTipe -> String
28glTipeName glTipe =
29 case glTipe of
30 Int -> "Int"
31 Float -> "Float"
32 V2 -> "Math.Vector2.Vec2"
33 V3 -> "Math.Vector3.Vec3"
34 V4 -> "Math.Vector4.Vec4"
35 M4 -> "Math.Matrix4.Mat4"
36 Texture -> "Graphics.WebGL.Texture"
38data GLShaderTipe = GLShaderTipe
39 { attribute :: Map String GLTipe
40 , uniform :: Map String GLTipe
41 , varying :: Map String GLTipe
42 } deriving (Show)