diff --git a/.gitignore b/.gitignore index d8cf097..15fe151 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,11 @@ -bin/ -/result -/config.dhall -/Dockerfile -.stack-work/ *.swp -dist* +*.txt *~ .env +.stack-work/ +/Dockerfile +/config.dhall +/result WD -*.hs.txt +bin/ +dist* diff --git a/src/Parser.hs b/src/Parser.hs index 0026dc0..28ec38b 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -54,16 +54,9 @@ parseFunction = do parseAtomicBase :: Parser TricuAST parseAtomicBase = choice - [ try parseVarWithoutAssignment - , parseTreeLeaf + [ parseTreeLeaf , parseGrouped ] -parseVarWithoutAssignment :: Parser TricuAST -parseVarWithoutAssignment = do - LIdentifier name <- satisfy isIdentifier - if (name == "t" || name == "__result") - then fail $ "Reserved keyword: " ++ name ++ " cannot be assigned." - else notFollowedBy (satisfy (== LAssign)) *> return (SVar name) parseLambda :: Parser TricuAST parseLambda = between (satisfy (== LOpenParen)) (satisfy (== LCloseParen)) $ do diff --git a/src/REPL.hs b/src/REPL.hs index 7911e44..44a6081 100644 --- a/src/REPL.hs +++ b/src/REPL.hs @@ -66,4 +66,6 @@ decodeResult tc = case toNumber tc of Right num -> show num Left _ -> case toString tc of Right str -> "\"" ++ str ++ "\"" - Left _ -> formatResult TreeCalculus tc + Left _ -> case toList tc of + Right list -> "[" ++ intercalate ", " (map decodeResult list) ++ "]" + Left _ -> formatResult TreeCalculus tc diff --git a/test/Spec.hs b/test/Spec.hs index ffac242..1fa8fd5 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -53,7 +53,7 @@ lexerTests = testGroup "Lexer Tests" expect = Right [LKeywordT, LStringLiteral "string", LIntegerLiteral 42] runParser tricuLexer "" input @?= expect , testCase "Lex invalid token" $ do - let input = "$invalid" + let input = "&invalid" case runParser tricuLexer "" input of Left _ -> return () Right _ -> assertFailure "Expected lexer to fail on invalid token"