From 6af1f804f0def7f48ae2d726951b13c895b85931 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Thu, 3 Mar 2022 21:40:07 +0100 Subject: Syntax and typing start --- src/Fun/Grammar.hs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'src/Fun/Grammar.hs') diff --git a/src/Fun/Grammar.hs b/src/Fun/Grammar.hs index 8014a20..7f6625d 100644 --- a/src/Fun/Grammar.hs +++ b/src/Fun/Grammar.hs @@ -2,6 +2,7 @@ module Fun.Grammar where import Fun.Parser import Fun.Tree +import Fun.Typer -- TODO: Multiple programs (= files) in tree tree :: Parser Tree @@ -11,14 +12,7 @@ program :: Parser Program program = iterFull block >>> Program "program" block :: Parser Block -block = - functionBlock - <+-> newline - >>> Block - <|> functionBlock - <+-> endOfFile - >>> Block - "block" +block = functionBlock <+-> newline <|> functionBlock <+-> endOfFile "block" visibility :: Parser Visibility visibility = @@ -26,7 +20,7 @@ visibility = <|> (literal '-' >>> const PrivateVisibility) "visibility" -functionBlock :: Parser FunctionBlock +functionBlock :: Parser Block functionBlock = functionDeclaration <+> iter functionDefinition >>> build where build (decl, defn) = FunctionBlock decl defn @@ -77,13 +71,13 @@ functionName = "function name" where build (first, rest) = first : rest -functionTypes :: Parser [String] +functionTypes :: Parser [Type] functionTypes = iter (functionType <+-> space <+-> functionTypeDelimiter <+-> space) <+> functionType >>> build "function types" - where build (a, b) = a ++ [b] + where build (a, b) = (map resolveType a) ++ [resolveType b] functionType :: Parser String functionType = -- cgit v1.2.3