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

Commit

Permalink
Remove some compil error
Browse files Browse the repository at this point in the history
PATCH
  • Loading branch information
Saverio976 committed Dec 4, 2023
1 parent a030bcd commit c21ab8f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/AST.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module AST
(
Symbol,
Atom (Number, Symbol, Boolean),
Tree (Node, Leaf, Variadic)
Tree (Node, Leaf, Variadic),
showMaybeTree
) where

Expand Down
17 changes: 9 additions & 8 deletions src/TextToAST.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,33 @@ notSkipableChar x = not (skipableChar x)

stringIsNumber :: String -> Bool
stringIsNumber [] = False
stringIsNumber (x:[]) | Data.Char.isDigit x = True
stringIsNumber [x] | Data.Char.isDigit x = True
| otherwise = False
stringIsNumber (x:xs) | Data.Char.isDigit x = stringIsNumber xs
| otherwise = False

nextToParse :: String -> String
nextToParse [] = []
nextToParse ('(':xs)
nextToParse str = dropWhile skipableChar (dropWhile notSkipableChar (dropWhile skipableChar (x:xs))
nextToParse ('(':xs) = xs
nextToParse str = dropWhile skipableChar (dropWhile notSkipableChar (dropWhile skipableChar str))

countAtoms :: String -> Int -> Int
countAtoms str depth | depth >= 2 = 2
| len str > 0 = countAtoms (nextToParse str) (depth + 1)
| not (null str) = countAtoms (nextToParse str) (depth + 1)
| otherwise = depth

createVariadic :: String -> Variadic
createVariadic str = Variadic (textToAST str) (textToAST (nextToParse str))
createVariadic :: String -> Maybe Tree
createVariadic str = Just $ Variadic (textToAST str) (textToAST (nextToParse str))

createNodeFromFunction :: Symbol -> String -> Int -> Maybe Tree
createNodeFromFunction [] _ _ = Nothing
createNodeFromFunction _ [] _ = Nothing
createNodeFromFunction (_:xs) str 0 = Just (Node xs Nothing Nothing)
createNodeFromFunction (_:xs) _ 0 = Just (Node xs Nothing Nothing)
createNodeFromFunction (_:xs) str 1 = Just (Node xs (textToAST str)
(checkNextToParse textToAST (nextToParse str)))

Check failure on line 55 in src/TextToAST.hs

View workflow job for this annotation

GitHub Actions / tests

Variable not in scope:

Check failure on line 55 in src/TextToAST.hs

View workflow job for this annotation

GitHub Actions / compil-linux

Variable not in scope:

Check failure on line 55 in src/TextToAST.hs

View workflow job for this annotation

GitHub Actions / compil-macos

Variable not in scope:

Check failure on line 55 in src/TextToAST.hs

View workflow job for this annotation

GitHub Actions / compil-windows

Variable not in scope:
createNodeFromFunction (_:xs) str 2 =
Just (Node xs (textToAST str) (createVariadic (nextToparse str)))
Just (Node xs (textToAST str) (createVariadic (nextToParse str)))
createNodeFromFunction _ _ _ = Nothing

stringIsBool :: String -> Bool
stringIsBool "#t" = True
Expand Down

0 comments on commit c21ab8f

Please sign in to comment.