Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

Commit

Permalink
Fix norm guard
Browse files Browse the repository at this point in the history
PATCH
  • Loading branch information
Saverio976 committed Dec 4, 2023
1 parent f5d5eb7 commit c81bc17
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/TextToAST.hs
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,25 @@ createNodeFromFunction _ _ _ = Nothing
stringIsBool :: String -> Bool
stringIsBool "#t" = True
stringIsBool "#f" = True
stringIsBool ('#':'t':xs) | xs == ")" = True
| dropWhile skipableChar xs == ")" = True
stringIsBool ('#':'f':xs) | xs == ")" = True
| dropWhile skipableChar xs == ")" = True
stringIsBool "#f)" = True
stringIsBool "#t)" = True
stringIsBool ('#':'t':xs) | dropWhile skipableChar xs == ")" = True
| otherwise = False
stringIsBool ('#':'f':xs) | dropWhile skipableChar xs == ")" = True
| otherwise = False
stringIsBool _ = False

createBool :: String -> Maybe Tree
createBool "#f" = Just (Leaf (Boolean False))
createBool "#t" = Just (Leaf (Boolean True))
createBool ('#':'t':xs) | xs == ")" = Just (Leaf (Boolean True))
| dropWhile skipableChar xs == ")" =
createBool "#f)" = Just (Leaf (Boolean False))
createBool "#t)" = Just (Leaf (Boolean True))
createBool ('#':'t':xs) | dropWhile skipableChar xs == ")" =
Just (Leaf (Boolean True))
createBool "#f" = Just (Leaf (Boolean False))
createBool ('#':'f':xs) | xs == ")" = Just (Leaf (Boolean False))
| dropWhile skipableChar xs == ")" =
| otherwise = Nothing
createBool ('#':'f':xs) | dropWhile skipableChar xs == ")" =
Just (Leaf (Boolean False))
| otherwise = Nothing
createBool _ = Nothing

treeFromAtom :: String -> String -> Maybe Tree
Expand Down

0 comments on commit c81bc17

Please sign in to comment.