Simplify getParseOutput

This commit is contained in:
Joseph C. Sible 2024-12-13 23:57:50 -05:00
parent 7deb7e853b
commit d3001f337a

View file

@ -3451,12 +3451,12 @@ isNotOk p s = parsesCleanly p s == Nothing -- The string does not parse
-- If the parser matches the string, return Right [ParseNotes+ParseProblems] -- If the parser matches the string, return Right [ParseNotes+ParseProblems]
-- If it does not match the string, return Left [ParseProblems] -- If it does not match the string, return Left [ParseProblems]
getParseOutput parser string = runIdentity $ do getParseOutput parser string = runIdentity $ do
(res, sys) <- runParser testEnvironment (res, systemState) <- runParser testEnvironment
(parser >> eof >> getState) "-" string (parser >> eof >> getState) "-" string
case (res, sys) of return $ case res of
(Right userState, systemState) -> Right userState ->
return $ Right $ parseNotes userState ++ parseProblems systemState Right $ parseNotes userState ++ parseProblems systemState
(Left _, systemState) -> return $ Left $ parseProblems systemState Left _ -> Left $ parseProblems systemState
-- If the parser matches the string, return Just whether it was clean (without emitting suggestions) -- If the parser matches the string, return Just whether it was clean (without emitting suggestions)
-- Otherwise, Nothing -- Otherwise, Nothing