simplify scanner error type

This commit is contained in:
Oleg Sobolev 2025-12-30 06:58:23 +03:00
parent ef7dc3603d
commit 8eeb671692
2 changed files with 8 additions and 8 deletions

View file

@ -8,7 +8,7 @@ run :: String -> IO ()
run source = do
let tokensMaybe = scanTokensFromSource source
case tokensMaybe of
Left UnexpectedCharacterError -> putStrLn "Unexpected character"
Left (LexicalError s) -> putStrLn s
Right tokens -> do
let stmtMaybe = parse tokens
case stmtMaybe of
@ -19,7 +19,7 @@ runEval :: String -> IO ()
runEval source = do
let tokensMaybe = scanTokensFromSource source
object <- case tokensMaybe of
Left UnexpectedCharacterError -> putStrLn "Unexpected character" >> return NullObject
Left (LexicalError s) -> putStrLn s >> return NullObject
Right tokens -> do
let exprMaybe = parseExpression tokens
case exprMaybe of