aboutsummaryrefslogtreecommitdiff
path: root/src/Fun/Tree.hs
blob: 7b21b17db44d0e4af1c36458d8330cd04eb620e1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
module Fun.Tree where

import           Fun.Typer

data Visibility = PublicVisibility | PrivateVisibility
  deriving Show
data FunctionFlag = FunctionInline | FunctionDeprecated | FunctionUnknown
  deriving Show
instance Read FunctionFlag where
  readsPrec _ "inline"     = [(FunctionInline, "")]
  readsPrec _ "deprecated" = [(FunctionDeprecated, "")]
  readsPrec _ _            = [(FunctionUnknown, "")]

data Tree = Tree [Program]
  deriving Show

data Program = Program [Block]
  deriving Show

data Block = FunctionBlock
  { bDecl  :: FunctionDeclaration
  , bDefns :: [FunctionDefinition]
  } -- | DataBlock .. TODO
  deriving Show

data FunctionDeclaration = FunctionDeclaration
  { dName       :: String
  , dVisibility :: Visibility
  , dTypes      :: [Type]
  , dFlags      :: [FunctionFlag]
  }
  deriving Show

data FunctionDefinition = FunctionDefinition
  { dPattern :: FunctionPattern
  , dBody    :: FunctionBody
  }
  deriving Show

data FunctionPattern = FunctionPattern
  { pElements :: [FunctionPatternElement]
  }
  deriving Show

data FunctionPatternElement = FunctionPatternParameter String | FunctionPatternString String | FunctionPatternNumber Integer | FunctionPatternWildcard | FunctionPatternSuperWildcard
  deriving Show

data FunctionBody = FunctionBody
  { bElements :: [FunctionBodyElement]
  }
  deriving Show

data FunctionBodyElement = Statement String | FunctionBodyIdentifier String | FunctionBodyParameter String | FunctionBodyString String | FunctionBodyNumber Integer
  deriving Show