Skip to content

Commit

Permalink
cli: Pretty-print syntax errors
Browse files Browse the repository at this point in the history
  • Loading branch information
langston-barrett committed Jan 22, 2025
1 parent 0f1b3b8 commit c94ceb7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions crucible-cli/src/Lang/Crucible/CLI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import Data.Map (Map)
import Data.Text (Text)
import Data.String (IsString(..))
import qualified Data.Text.IO as T
import qualified Prettyprinter as PP
import qualified Prettyprinter.Render.Text as PP
import System.IO
import System.Exit
import Text.Megaparsec as MP
Expand All @@ -43,7 +45,6 @@ import Lang.Crucible.CFG.SSAConversion

import Lang.Crucible.Syntax.Atoms
import Lang.Crucible.Syntax.Concrete
import Lang.Crucible.Syntax.ExprParse (printSyntaxError)
import Lang.Crucible.Syntax.Prog (doParseCheck, assertNoExterns, assertNoForwardDecs)
import Lang.Crucible.Syntax.SExpr

Expand Down Expand Up @@ -139,8 +140,8 @@ simulateProgramWithExtension mkExt fn theInput outh profh opts hooks =
let hdls = [ (SomeHandle h, p) | (FnBinding h _,p) <- ovrs ]
parseResult <- top ng ha hdls $ prog v
case parseResult of
Left (SyntaxParseError e) -> T.hPutStrLn outh $ printSyntaxError e
Left err -> hPutStrLn outh $ show err
Left e ->
T.hPutStrLn outh (PP.renderStrict (PP.layoutPretty PP.defaultLayoutOptions (PP.pretty e)))
Right (ParsedProgram{ parsedProgCFGs = cs
, parsedProgExterns = externs
, parsedProgForwardDecs = fds
Expand Down

0 comments on commit c94ceb7

Please sign in to comment.