diff options
Diffstat (limited to 'src/Fun/Tree.hs')
-rw-r--r-- | src/Fun/Tree.hs | 50 |
1 files changed, 33 insertions, 17 deletions
diff --git a/src/Fun/Tree.hs b/src/Fun/Tree.hs index 63ca0b5..7b21b17 100644 --- a/src/Fun/Tree.hs +++ b/src/Fun/Tree.hs @@ -2,37 +2,53 @@ 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 FunctionDeclaration [FunctionDefinition] -- | DataBlock .. TODO +data Block = FunctionBlock + { bDecl :: FunctionDeclaration + , bDefns :: [FunctionDefinition] + } -- | DataBlock .. TODO deriving Show -data Visibility = PublicVisibility | PrivateVisibility +data FunctionDeclaration = FunctionDeclaration + { dName :: String + , dVisibility :: Visibility + , dTypes :: [Type] + , dFlags :: [FunctionFlag] + } deriving Show -data FunctionDeclaration = FunctionDeclaration String - Visibility - [Type] - [FunctionFlag] +data FunctionDefinition = FunctionDefinition + { dPattern :: FunctionPattern + , dBody :: FunctionBody + } deriving Show -data FunctionFlag = FunctionInline | FunctionDeprecated | FunctionUnknown - deriving Show -instance Read FunctionFlag where - readsPrec _ "inline" = [(FunctionInline, "")] - readsPrec _ "deprecated" = [(FunctionDeprecated, "")] - readsPrec _ _ = [(FunctionUnknown, "")] -data FunctionDefinition = FunctionDefinition FunctionPattern FunctionBody - deriving Show -data FunctionPattern = FunctionPattern [FunctionPatternElement] +data FunctionPattern = FunctionPattern + { pElements :: [FunctionPatternElement] + } deriving Show -data FunctionPatternElement = FunctionPatternParameter String | FunctionPatternString String | FunctionPatternNumber Integer | FunctionPatternWildcard + +data FunctionPatternElement = FunctionPatternParameter String | FunctionPatternString String | FunctionPatternNumber Integer | FunctionPatternWildcard | FunctionPatternSuperWildcard deriving Show -data FunctionBody = FunctionBody [FunctionBodyElement] + +data FunctionBody = FunctionBody + { bElements :: [FunctionBodyElement] + } deriving Show + data FunctionBodyElement = Statement String | FunctionBodyIdentifier String | FunctionBodyParameter String | FunctionBodyString String | FunctionBodyNumber Integer deriving Show |