Skip to content

Commit

Permalink
add support for running "l4 epilog" as well as "l4 asp"
Browse files Browse the repository at this point in the history
  • Loading branch information
mengwong committed Sep 19, 2022
1 parent 9a185c2 commit 1858b51
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .ghci
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
:set -isrc
-- Don't spam a ton of warnings
-- :set -Wno-incomplete-patterns -Wno-unused-imports -Wno-name-shadowing -Wno-unused-top-binds -Wno-missing-signatures
:l tests/DisambiguateTest.hs tests/ExpSysTest.hs tests/Test.hs tests/ToGFTest.hs
1 change: 1 addition & 0 deletions .ghcid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--test=":main --rerun-all-on-success" --warn
1 change: 1 addition & 0 deletions baby-l4.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ library
ToGF.FromSCasp.ToAnswer
ToGF.FromL4.ToQuestions
ToGF.FromL4.ToAnswers
ToEpilog
ToASP
ToSCASP
ToDA2
Expand Down
5 changes: 4 additions & 1 deletion exe/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import ToDA2 (createDSyaml)
import SimpleRules ( expSys )
import ToRules.FromL4 (genREP)
import ToASP (astToASP)
import ToEpilog (astToEpilog)



Expand All @@ -53,6 +54,7 @@ process args input = do
normalAst = normalizeProg tpAstNoSrc -- Creates predicates of class fields

case format args of
Fepilog -> astToEpilog tpAstNoSrc
Fasp -> astToASP tpAstNoSrc
Fast -> pPrint tpAst
(Fgf GFOpts { gflang = gfl, showast = True } ) -> GF.nlgAST gfl fpath normalAst
Expand All @@ -70,7 +72,7 @@ process args input = do
(Fexpsys Rules) -> genREP tpAstNoSrc


data Format = Fasp | Fast | Fgf GFOpts | Fscasp | Fsmt | Fyaml | Fexpsys ESOpts
data Format = Fepilog | Fasp | Fast | Fgf GFOpts | Fscasp | Fsmt | Fyaml | Fexpsys ESOpts
deriving Show

-- l4 gf en output english only
Expand All @@ -97,6 +99,7 @@ optsParse :: Parser InputOpts
optsParse = InputOpts <$>
subparser
( command "gf" (info gfSubparser gfHelper)
<> command "epilog" (info (pure Fepilog) (progDesc "output to Epilog"))
<> command "asp" (info (pure Fasp) (progDesc "output to ASP / Clingo"))
<> command "ast" (info (pure Fast) (progDesc "Show the AST in Haskell"))
<> command "scasp" (info (pure Fscasp) (progDesc "output to sCASP for DocAssemble purposes"))
Expand Down
6 changes: 3 additions & 3 deletions src/ToEpilog.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{-# LANGUAGE OverloadedStrings #-}

module ToASP where
module ToEpilog where

import Prettyprinter
import Prettyprinter.Render.Text (putDoc)
Expand Down Expand Up @@ -386,8 +386,8 @@ genOppClause (posvar, negvar, n) =
let args = zipWith (\ vn i -> LocalVar (QVarName IntegerT (vn ++ show i)) i) (replicate n "V") [0 .. n-1]
in OpposesClause (applyVars posvar args) (applyVars negvar args)

astToASP :: Program (Tp ()) -> IO ()
astToASP prg = do
astToEpilog :: Program (Tp ()) -> IO ()
astToEpilog prg = do
let rules = concatMap ruleDisjL (clarify (rulesOfProgram prg))
-- putStrLn "Simplified L4 rules:"
-- putDoc $ vsep (map (showL4 []) rules) <> line
Expand Down

0 comments on commit 1858b51

Please sign in to comment.