Additional test cases and bug fixes for subtle issues
This commit is contained in:
@ -20,6 +20,7 @@ data SaplingAST
|
||||
deriving (Show, Eq, Ord)
|
||||
|
||||
parseSapling :: String -> SaplingAST
|
||||
parseSapling "" = error "Empty input provided to parseSapling"
|
||||
parseSapling input = case runParser parseExpression "" (lexSapling input) of
|
||||
Left err -> error "Failed to parse input"
|
||||
Right ast -> ast
|
||||
@ -122,8 +123,14 @@ parseListLiteral = do
|
||||
satisfy (== LCloseBracket)
|
||||
return (SList elements)
|
||||
|
||||
--parseListItem :: Parser SaplingAST
|
||||
--parseListItem = parseGroupedItem <|> parseSingleItem
|
||||
parseListItem :: Parser SaplingAST
|
||||
parseListItem = parseGroupedItem <|> parseSingleItem
|
||||
parseListItem = choice
|
||||
[ parseGroupedItem -- Handle expressions inside parentheses
|
||||
, parseListLiteral -- Allow nested lists
|
||||
, parseSingleItem -- Handle single tokens like `t` or identifiers
|
||||
]
|
||||
|
||||
parseGroupedItem :: Parser SaplingAST
|
||||
parseGroupedItem = do
|
||||
|
Reference in New Issue
Block a user