diff --git a/app/Main.hs b/app/Main.hs index 351592f..959943c 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -8,8 +8,8 @@ developProgram :: String developProgram = -- "int i = 1; int j = 2; int l = 3 + 4; int k = i + j + l; k = k * 0;" -- "void test(int i, int k) { }" - -- "int main() { print(); }" - "print()" + -- "print()" + "int main() { print(); }" main :: IO () main = do diff --git a/src/Interpreter/BuiltIn.hs b/src/Interpreter/BuiltIn.hs index 4290cab..a75a6b9 100644 --- a/src/Interpreter/BuiltIn.hs +++ b/src/Interpreter/BuiltIn.hs @@ -20,6 +20,6 @@ printBuiltIn = [CustomType "String"] UnitType ( \[CustomType "String"] -> do - putStrLn "Hello, World!" + putStrLn "Hello, World!\n" pure UnitType ) diff --git a/src/Interpreter/Interpreter.hs b/src/Interpreter/Interpreter.hs index f06487c..9ad6f10 100644 --- a/src/Interpreter/Interpreter.hs +++ b/src/Interpreter/Interpreter.hs @@ -28,7 +28,9 @@ interpret (Program statements) = do where addMainFunctionCall = if hasMainFunction then mainFunctionCall else [] mainFunctionCall = [ExpressionStatement (AtomicExpression (FunctionCallAtomic "main" []))] - hasMainFunction = False + hasMainFunction = Prelude.filter isMainFunction statements /= [] + isMainFunction (FunctionDefinitionStatement (Function "main" _ _ _)) = True + isMainFunction _ = False isFunctionDefinition (FunctionDefinitionStatement _) = True isFunctionDefinition _ = False getFunctionName (FunctionDefinitionStatement (Function name _ _ _)) = name