inferred funtypes added
authorMart Lubbers <mart@martlubbers.net>
Mon, 29 Feb 2016 13:18:15 +0000 (14:18 +0100)
committerMart Lubbers <mart@martlubbers.net>
Mon, 29 Feb 2016 13:18:15 +0000 (14:18 +0100)
src/main.prj
src/parse.dcl
src/parse.icl

index f0b6422..f7fe0c7 100644 (file)
@@ -31,7 +31,6 @@ Global
        Link
                LinkMethod:     Static
                GenerateRelocations:    False
-               GenerateSymbolTable:    False
                GenerateLinkMap:        False
                LinkResources:  False
                ResourceSource: 
@@ -420,37 +419,9 @@ OtherModules
                        ReadableABC:    False
                        ReuseUniqueNodes:       True
                        Fusion: False
-       Module
-               Name:   System.OS
-               Dir:    {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Linux-64
-               Compiler
-                       NeverMemoryProfile:     False
-                       NeverTimeProfile:       False
-                       StrictnessAnalysis:     True
-                       ListTypes:      StrictExportTypes
-                       ListAttributes: True
-                       Warnings:       True
-                       Verbose:        True
-                       ReadableABC:    False
-                       ReuseUniqueNodes:       True
-                       Fusion: False
-       Module
-               Name:   System.OS
-               Dir:    {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Linux-64
-               Compiler
-                       NeverMemoryProfile:     False
-                       NeverTimeProfile:       False
-                       StrictnessAnalysis:     True
-                       ListTypes:      StrictExportTypes
-                       ListAttributes: True
-                       Warnings:       True
-                       Verbose:        True
-                       ReadableABC:    False
-                       ReuseUniqueNodes:       True
-                       Fusion: False
        Module
                Name:   Control.Applicative
-               Dir:    {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent
+               Dir:    {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
                Compiler
                        NeverMemoryProfile:     False
                        NeverTimeProfile:       False
@@ -464,7 +435,7 @@ OtherModules
                        Fusion: False
        Module
                Name:   Control.Monad
-               Dir:    {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent
+               Dir:    {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
                Compiler
                        NeverMemoryProfile:     False
                        NeverTimeProfile:       False
@@ -478,7 +449,7 @@ OtherModules
                        Fusion: False
        Module
                Name:   Data.Either
-               Dir:    {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent
+               Dir:    {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
                Compiler
                        NeverMemoryProfile:     False
                        NeverTimeProfile:       False
@@ -492,7 +463,7 @@ OtherModules
                        Fusion: False
        Module
                Name:   Data.Foldable
-               Dir:    {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent
+               Dir:    {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
                Compiler
                        NeverMemoryProfile:     False
                        NeverTimeProfile:       False
@@ -506,7 +477,7 @@ OtherModules
                        Fusion: False
        Module
                Name:   Data.Func
-               Dir:    {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent
+               Dir:    {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
                Compiler
                        NeverMemoryProfile:     False
                        NeverTimeProfile:       False
@@ -520,7 +491,7 @@ OtherModules
                        Fusion: False
        Module
                Name:   Data.Functor
-               Dir:    {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent
+               Dir:    {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
                Compiler
                        NeverMemoryProfile:     False
                        NeverTimeProfile:       False
@@ -534,7 +505,7 @@ OtherModules
                        Fusion: False
        Module
                Name:   Data.List
-               Dir:    {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent
+               Dir:    {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
                Compiler
                        NeverMemoryProfile:     False
                        NeverTimeProfile:       False
@@ -548,7 +519,7 @@ OtherModules
                        Fusion: False
        Module
                Name:   Data.Map
-               Dir:    {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent
+               Dir:    {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
                Compiler
                        NeverMemoryProfile:     False
                        NeverTimeProfile:       False
@@ -562,7 +533,7 @@ OtherModules
                        Fusion: False
        Module
                Name:   Data.Maybe
-               Dir:    {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent
+               Dir:    {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
                Compiler
                        NeverMemoryProfile:     False
                        NeverTimeProfile:       False
@@ -576,7 +547,7 @@ OtherModules
                        Fusion: False
        Module
                Name:   Data.Monoid
-               Dir:    {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent
+               Dir:    {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
                Compiler
                        NeverMemoryProfile:     False
                        NeverTimeProfile:       False
@@ -590,7 +561,7 @@ OtherModules
                        Fusion: False
        Module
                Name:   Data.Set
-               Dir:    {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent
+               Dir:    {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
                Compiler
                        NeverMemoryProfile:     False
                        NeverTimeProfile:       False
@@ -604,7 +575,7 @@ OtherModules
                        Fusion: False
        Module
                Name:   Data.Traversable
-               Dir:    {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent
+               Dir:    {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
                Compiler
                        NeverMemoryProfile:     False
                        NeverTimeProfile:       False
@@ -618,7 +589,7 @@ OtherModules
                        Fusion: False
        Module
                Name:   Data.Void
-               Dir:    {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent
+               Dir:    {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
                Compiler
                        NeverMemoryProfile:     False
                        NeverTimeProfile:       False
@@ -632,7 +603,7 @@ OtherModules
                        Fusion: False
        Module
                Name:   System.CommandLine
-               Dir:    {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent
+               Dir:    {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
                Compiler
                        NeverMemoryProfile:     False
                        NeverTimeProfile:       False
@@ -646,7 +617,7 @@ OtherModules
                        Fusion: False
        Module
                Name:   System.IO
-               Dir:    {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent
+               Dir:    {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
                Compiler
                        NeverMemoryProfile:     False
                        NeverTimeProfile:       False
@@ -660,7 +631,7 @@ OtherModules
                        Fusion: False
        Module
                Name:   System._Pointer
-               Dir:    {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent
+               Dir:    {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
                Compiler
                        NeverMemoryProfile:     False
                        NeverTimeProfile:       False
@@ -674,7 +645,7 @@ OtherModules
                        Fusion: False
        Module
                Name:   Text
-               Dir:    {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent
+               Dir:    {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
                Compiler
                        NeverMemoryProfile:     False
                        NeverTimeProfile:       False
@@ -688,7 +659,7 @@ OtherModules
                        Fusion: False
        Module
                Name:   Text.JSON
-               Dir:    {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent
+               Dir:    {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
                Compiler
                        NeverMemoryProfile:     False
                        NeverTimeProfile:       False
@@ -702,7 +673,7 @@ OtherModules
                        Fusion: False
        Module
                Name:   Text.PPrint
-               Dir:    {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent
+               Dir:    {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
                Compiler
                        NeverMemoryProfile:     False
                        NeverTimeProfile:       False
@@ -715,8 +686,22 @@ OtherModules
                        ReuseUniqueNodes:       True
                        Fusion: False
        Module
-               Name:   StdMaybe
-               Dir:    {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent/Deprecated/StdLib
+               Name:   System.OS
+               Dir:    {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Linux-64
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False
+       Module
+               Name:   System.OS
+               Dir:    {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Linux-64
                Compiler
                        NeverMemoryProfile:     False
                        NeverTimeProfile:       False
@@ -784,3 +769,17 @@ OtherModules
                        ReadableABC:    False
                        ReuseUniqueNodes:       True
                        Fusion: False
+       Module
+               Name:   StdMaybe
+               Dir:    {Application}/lib/iTasks-SDK/Server/lib
+               Compiler
+                       NeverMemoryProfile:     False
+                       NeverTimeProfile:       False
+                       StrictnessAnalysis:     True
+                       ListTypes:      StrictExportTypes
+                       ListAttributes: True
+                       Warnings:       True
+                       Verbose:        True
+                       ReadableABC:    False
+                       ReuseUniqueNodes:       True
+                       Fusion: False
index 62a0461..55d8a95 100644 (file)
@@ -32,7 +32,7 @@ import lex
 :: Op1 = UnNegation | UnMinus
 :: Op2 = BiPlus | BiMinus | BiTimes | BiDivide | BiMod | BiEquals | BiLesser |
        BiGreater | BiLesserEq | BiGreaterEq | BiUnEqual | BiAnd | BiOr | BiCons
-:: FunDecl = FunDecl String [String] FunType [VarDecl] [Stmt]
+:: FunDecl = FunDecl String [String] (Maybe FunType) [VarDecl] [Stmt]
 :: FunType = FunType [Type] (Maybe Type)
 :: FunCall = FunCall String [Expr]
 :: Stmt 
index cfd4fd1..fc6e740 100644 (file)
@@ -24,13 +24,14 @@ parser (Right r) = case runParser parseProgram r of
        (Left e, _) = Left $ toString e
 
 parseProgram :: Parser Token AST
-parseProgram = liftM2 AST (many parseVarDecl) (some parseFunDecl)
+parseProgram = liftM2 AST (many parseVarDecl) (some parseFunDecl) 
+       <* satTok EndOfFileToken
 
 parseFunDecl :: Parser Token FunDecl
 parseFunDecl = liftM5 FunDecl
        (parseIdent <* satTok BraceOpenToken)
        (parseSepList CommaToken parseIdent <* satTok BraceCloseToken)
-       (parseFunType <* satTok CBraceOpenToken)
+       (optional parseFunType <* satTok CBraceOpenToken)
        (many parseVarDecl)
        (many parseStmt <* satTok CBraceCloseToken)
 
@@ -69,7 +70,7 @@ parseStmt = parseIfStmt <|> parseWhileStmt <|>
                parseOneLine = liftM pure parseStmt
 
 parseFunType :: Parser Token FunType
-parseFunType = satTok DoubleColonToken *>
+parseFunType = satTok DoubleColonToken *> 
        (parseInOutType <|> (liftM (FunType []) parseVoidOrType))
        where
                parseInOutType :: Parser Token FunType
@@ -78,7 +79,7 @@ parseFunType = satTok DoubleColonToken *>
 
                parseVoidOrType :: Parser Token (Maybe Type)
                parseVoidOrType = (satTok VoidToken *> pure Nothing) <|> 
-                       (liftM Just parseType)
+                       (liftM Just parseType) <|> pure Nothing
 
 parseVarDecl :: Parser Token VarDecl
 parseVarDecl = liftM3 VarDecl
@@ -203,7 +204,7 @@ printersperse i j = intercalate [i] (map print j)
 instance print FunDecl where
        print (FunDecl i as t vs ss) =
                ["\n", i, " (":printersperse "," as] ++
-               [") :: ":print t] ++
+               [")"] ++ maybe [] (\tt->[" :: ":print tt]) t ++
                ["{\n\t":printersperse "\n\t" vs] ++
                ["\n":printStatements ss 1] ++ ["}\n"]