-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR contains a number of small misc dev tools/fixes: * Add `pretty`, a KORE JSON pretty printer util, useful when looking at bug reports without the original k definition (If we have the K definition, It's better to call pyk's pretty printer). The README has been updated with a sample use-case invocation. * Fix performance scripts, `kevm-dist` -> `kdist` * Modify the nix shell to automatically call `hpack` when the shell is re-loaded, useful to keep the local cabal files in sync with `package.yaml` * Cleanup the README, removing references to stale nix stuff related to the dev shell. --------- Co-authored-by: github-actions <github-actions@github.com>
- Loading branch information
1 parent
c90f7a2
commit e6752d1
Showing
6 changed files
with
76 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{-# LANGUAGE PatternSynonyms #-} | ||
|
||
{- | Pretty printer for JSON KORE terms | ||
Copyright : (c) Runtime Verification, 2022 | ||
License : BSD-3-Clause | ||
-} | ||
module Main ( | ||
main, | ||
) where | ||
|
||
import Booster.Prettyprinter (renderDefault) | ||
import Booster.Syntax.Json (KoreJson (..)) | ||
import Booster.Syntax.Json.Internalise ( | ||
internalisePattern, | ||
pattern CheckSubsorts, | ||
pattern DisallowAlias, | ||
) | ||
import Booster.Syntax.ParsedKore (internalise, parseKoreDefinition) | ||
import Control.Monad.Trans.Except | ||
import Data.Aeson (eitherDecode) | ||
import Data.ByteString.Lazy qualified as BS | ||
import Data.Text.IO qualified as Text | ||
import Prettyprinter | ||
import System.Environment (getArgs) | ||
|
||
main :: IO () | ||
main = do | ||
[def, json] <- getArgs | ||
parsedDef <- | ||
either (error . renderDefault . pretty) id . parseKoreDefinition def <$> Text.readFile def | ||
let internalDef = either (error . renderDefault . pretty) id $ internalise Nothing parsedDef | ||
|
||
fileContent <- BS.readFile json | ||
case eitherDecode fileContent of | ||
Left err -> putStrLn $ "Error: " ++ err | ||
Right KoreJson{term} -> do | ||
let (trm, _subst) = | ||
either (error . show) id $ | ||
runExcept $ | ||
internalisePattern DisallowAlias CheckSubsorts Nothing internalDef term | ||
putStrLn $ renderDefault $ pretty trm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters