diff options
author | Marvin Borner | 2022-03-04 01:10:12 +0100 |
---|---|---|
committer | Marvin Borner | 2022-03-04 01:10:12 +0100 |
commit | dbfb7c4f285fda49c59648ef16c6d6bfdd4e59bd (patch) | |
tree | 9b44a3dcb6ab087569293489700177c7d5709f41 /src/Fun/Tree.hs | |
parent | 6af1f804f0def7f48ae2d726951b13c895b85931 (diff) |
Syntax
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 |