Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from ansi-wl-pprint to prettyprinter package. #28

Merged
merged 2 commits into from
Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ jobs:
with:
submodules: 'true'

- uses: actions/setup-haskell@v1.1
id: setup-haskell-cabal
- uses: actions/setup-haskell@v1
id: setup-haskell
name: Setup Haskell
with:
ghc-version: ${{ matrix.ghc }}
Expand Down
2 changes: 1 addition & 1 deletion asl-translator.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ common shared-properties
mtl,
transformers,
lens,
ansi-wl-pprint,
parameterized-utils >= 2.1.1,
pretty,
prettyprinter >= 1.7.0,
crucible,
what4,
asl-parser,
Expand Down
8 changes: 5 additions & 3 deletions lib/Language/ASL.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ import qualified Language.ASL.Signature as AS
import qualified Language.ASL.Types as AT
import qualified Language.ASL.Globals as G

import qualified Prettyprinter as LPP
import qualified Prettyprinter.Render.String as LPP
import qualified Text.PrettyPrint.HughesPJClass as PP
import qualified Text.PrettyPrint.ANSI.Leijen as LPP

data SimulatorConfig scope =
SimulatorConfig { simOutputHandle :: IO.Handle
Expand Down Expand Up @@ -413,8 +414,9 @@ instance Show SimulationException where
show e = PP.render (PP.pPrint e)

showExpr :: S.Expr t ret -> PP.Doc
showExpr e = PP.text (LPP.displayS (LPP.renderPretty 0.4 80 (WI.printSymExpr e)) "")

showExpr e = PP.text (LPP.renderString (LPP.layoutPretty opts (WI.printSymExpr e)))
where opts = LPP.LayoutOptions (LPP.AvailablePerLine 80 0.4)

showAbortedResult :: CS.AbortedResult c d -> T.Text
showAbortedResult ar = case ar of
CS.AbortedExec reason _ -> T.pack $ show reason
Expand Down
26 changes: 13 additions & 13 deletions lib/Language/ASL/Crucible/Extension.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import qualified Lang.Crucible.Simulator.Evaluation as CSE
import qualified Lang.Crucible.Simulator.GlobalState as CSG
import qualified Lang.Crucible.Simulator.RegValue as CSR
import qualified Lang.Crucible.Types as CT
import qualified Text.PrettyPrint.ANSI.Leijen as PP
import qualified Prettyprinter as PP
import qualified What4.BaseTypes as WT
import qualified What4.Interface as WI
import qualified What4.Symbol as WS
Expand Down Expand Up @@ -240,12 +240,12 @@ instance CCExt.PrettyApp (ASLStmt arch) where
ppApp pp a =
case a of
GetRegState _reps regs ->
PP.hsep [ PP.text "GetRegState"
, PP.brackets (PP.cat (PP.punctuate PP.comma (FC.toListFC (PP.text . showF) regs)))
PP.hsep [ PP.pretty "GetRegState"
, PP.brackets (PP.cat (PP.punctuate PP.comma (FC.toListFC (PP.pretty . showF) regs)))
]
SetRegState gvs vs ->
PP.hsep [ PP.text "SetRegState"
, PP.brackets (PP.cat (PP.punctuate PP.comma (FC.toListFC (PP.text . showF) gvs)))
PP.hsep [ PP.pretty "SetRegState"
, PP.brackets (PP.cat (PP.punctuate PP.comma (FC.toListFC (PP.pretty . showF) gvs)))
, PP.comma
, PP.brackets (pp vs)
]
Expand Down Expand Up @@ -283,20 +283,20 @@ instance CCExt.PrettyApp ASLApp where
ppApp pp a =
case a of
UF name fresh trep argReps vals ->
PP.hsep [ PP.text (T.unpack name)
, PP.text (show fresh)
, PP.text (show trep)
, PP.brackets (PP.cat (PP.punctuate PP.comma (FC.toListFC (PP.text . showF) argReps)))
PP.hsep [ PP.pretty name
, PP.viaShow fresh
, PP.viaShow trep
, PP.brackets (PP.cat (PP.punctuate PP.comma (FC.toListFC (PP.pretty . showF) argReps)))
, PP.brackets (PP.cat (PP.punctuate PP.comma (FC.toListFC pp vals)))
]
GetBaseStruct _r i t ->
PP.hsep [ PP.text "GetBaseStruct"
, PP.text (showF i)
PP.hsep [ PP.pretty "GetBaseStruct"
, PP.pretty (showF i)
, pp t
]
MkBaseStruct _r _mems ->
PP.hsep [ PP.text "MkBaseStruct"
, PP.text "PP UNIMPLEMENTED"
PP.hsep [ PP.pretty "MkBaseStruct"
, PP.pretty "PP UNIMPLEMENTED"
]

instance FC.TestEqualityFC ASLApp where
Expand Down
6 changes: 4 additions & 2 deletions lib/Language/ASL/Translation/Driver.hs
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,9 @@ import What4.ProblemFeatures

import qualified What4.Serialize.Normalize as WN

import qualified Prettyprinter as LPP
import qualified Prettyprinter.Render.String as LPP
import qualified Text.PrettyPrint.HughesPJClass as PP
import qualified Text.PrettyPrint.ANSI.Leijen as LPP

import What4.Utils.Log ( HasLogCfg, LogCfg, withLogCfg )
import qualified What4.Utils.Log as Log
Expand Down Expand Up @@ -620,7 +621,8 @@ prettySymFnBody symFn = case B.symFnInfo symFn of
_ -> PP.text "[[uninterpreted]]"

showExpr :: B.Expr t ret -> PP.Doc
showExpr e = PP.text (LPP.displayS (LPP.renderPretty 0.4 80 (WI.printSymExpr e)) "")
showExpr e = PP.text (LPP.renderString (LPP.layoutPretty opts (WI.printSymExpr e)))
where opts = LPP.LayoutOptions (LPP.AvailablePerLine 80 0.4)

doSimulation :: TranslatorOptions
-> CFH.HandleAllocator
Expand Down
2 changes: 1 addition & 1 deletion submodules/crucible
Submodule crucible updated 135 files