Skip to content

Commit

Permalink
Merge branch 'dmn' into smtgen
Browse files Browse the repository at this point in the history
  • Loading branch information
johsi-k committed Nov 30, 2022
2 parents ba98e56 + 1a9550e commit ba0576b
Show file tree
Hide file tree
Showing 18 changed files with 1,877 additions and 20 deletions.
8 changes: 4 additions & 4 deletions baby-l4-core/src/L4/SyntaxManipulation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ gteExpr = BinOpE BooleanT (BCompar BCgte)
mkEq :: Var (Tp()) -> Var (Tp()) -> Expr (Tp())
mkEq v1 v2 = eqExpr (mkVarE v1) (mkVarE v2)

isTrueV :: Expr t -> Bool
isTrueV :: Expr t -> Bool
isTrueV (ValE _ (BoolV True)) = True
isTrueV _ = False
isTrueV _ = False

isFalseV :: Expr t -> Bool
isFalseV :: Expr t -> Bool
isFalseV (ValE _ (BoolV False)) = True
isFalseV _ = False
isFalseV _ = False


-- Decompose list of successive applications of the same binary operator
Expand Down
21 changes: 21 additions & 0 deletions baby-l4.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ library
ToRules.FromL4
ToRules.ToDecls
ToRules.ToRules
-- ToDMN
ToDMN.Types
ToDMN.FromL4
ToDMN.FromSimpleToReg
ToDMN.Picklers
--ExampleInput
Exec
--InterfaceNunchaku
Expand Down Expand Up @@ -153,6 +158,8 @@ library
, transformers
, rope-utf16-splay
, mmorph
, random
, hxt
default-language: Haskell2010
ghc-options: -Wall

Expand Down Expand Up @@ -212,6 +219,20 @@ executable lsp-server-bl4
, baby-l4
ghc-options: -Wall


executable hxtread
hs-source-dirs: hxtread
main-is: Main.hs
other-modules: Paths_baby_l4, DecTables
-- ghc-options: -threaded -rtsopts -with-rtsopts=-N
build-depends:
base >=4.7 && <5
, hxt
, hxt-css
, baby-l4
, baby-l4-core
default-language: Haskell2010

test-suite lsp-server-tests
default-language:
Haskell2010
Expand Down
34 changes: 18 additions & 16 deletions exe/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ import Control.Monad.Except (runExceptT)
import ToDA2 (createDSyaml)
import SimpleRules ( expSys )
import ToRules.FromL4 (genREP)
import ToDMN.FromL4 (genDMN)
import ToASP (astToASP)
import ToEpilog (astToEpilog)



process :: InputOpts -> String -> IO ()
process args input = do
let fpath = filepath args
Expand All @@ -54,25 +54,26 @@ 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
(Fexpsys Graph) -> expSys tpAstNoSrc
-- (Fexpsys Rules) -> astToRules tpAstNoSrc
(Fexpsys Rules) -> genREP tpAstNoSrc
(Fgf GFOpts { gflang = gfl, showast = True } ) -> GF.nlgAST gfl fpath normalAst
(Fgf GFOpts { gflang = gfl, showast = False} ) -> GF.nlg gfl fpath normalAst
Fsmt -> proveProgram tpAstNoSrc
Fscasp -> createSCasp normalAst
Fyaml -> do createDSyaml tpAstNoSrc
putStrLn "---------------"
putStrLn "WIP: create the questions with GF. Below is the current progress. They are not used yet in the yaml."
createQuestions fpath normalAst
putStrLn "---------------"
createPGFforAnswers fpath normalAst
(Fexpsys Graph) -> expSys tpAstNoSrc
-- (Fexpsys Rules) -> astToRules tpAstNoSrc
(Fexpsys Rules) -> genREP tpAstNoSrc


data Format = Fepilog | Fasp | Fast | Fgf GFOpts | Fscasp | Fsmt | Fyaml | Fexpsys ESOpts
Fdmn -> genDMN tpAstNoSrc
Fepilog -> astToEpilog tpAstNoSrc
Fscasp -> createSCasp normalAst
Fsmt -> proveProgram tpAstNoSrc
Fyaml -> do createDSyaml tpAstNoSrc
putStrLn "---------------"
putStrLn "WIP: create the questions with GF. Below is the current progress. They are not used yet in the yaml."
createQuestions fpath normalAst
putStrLn "---------------"
createPGFforAnswers fpath normalAst


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

-- l4 gf en output english only
Expand Down Expand Up @@ -106,6 +107,7 @@ optsParse = InputOpts <$>
<> command "smt" (info (pure Fsmt) (progDesc "Check assertion with SMT solver"))
<> command "yaml" (info (pure Fyaml) (progDesc "output to YAML for DocAssemble purposes"))
<> command "expsys" (info esSubparser esHelper)
<> command "dmn" (info (pure Fdmn) (progDesc "DMN test"))
)
<*> switch (long "testModels" <> help "Demo of NLG from sCASP models")
<*> argument str (metavar "Filename")
Expand Down
107 changes: 107 additions & 0 deletions hxtread/DecTables.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
module DecTables where

import ToDMN.Types

testDefs :: Definitions
testDefs =
Definitions
{ sXmlns = "https://www.omg.org/spec/DMN/20191111/MODEL/"
, sXmlnsDmndi = "https://www.omg.org/spec/DMN/20191111/DMNDI/"
, sXmlnsDc = "http://www.omg.org/spec/DMN/20180521/DC/"
, sXmlnsModeler = "http://camunda.org/schema/modeler/1.0"
, sXmlnsDi = "http://www.omg.org/spec/DMN/20180521/DI/"
, sDefId = "Definitions_1"
, sDefName = "myDRD"
, sNamespace = "http://camunda.org/schema/1.0/dmn"
, sExporter = "Camunda Modeler"
, sExporterVersion = "5.1.0"
, sModelerExPlat = "Camunda Cloud"
, sModelerExPlatVer = "8.0.0"
, sDecisions =
[ Decision
{ sDecId = "O"
, sDecName = "O"
, sDecOutVar = DecOutVar
{ sDecVarId = "InformationItem_1"
, sDecVarName = "O"
, sDecVarFEELType = "number"
}
, sDecTableInfoReqs =
[ ReqInputEl
{ sReqInputId = "InformationRequirement_1"
, sReqInput = "#P1"
}
]
, sDecTableOrLitExpr = DecTable
{ sDecTableId = "DecisionTable_1"
, sSchema = Schema
{ sInputSchemas =
[ InputSchema
{ sInputSchemaId = "InputClause_1"
, sInputLabel = Just "optional input label"
, sInputExprEl = InputExprEl
{ sInputExprElId = "LiteralExpression_1"
, sInputExprFEELType = "number"
, sInputExprVarName = XMLText { sText = "P1" }
}
}
]
, sOutputSchema = OutputSchema
{ sOutputSchemaId = "OutputClause_1"
, sOutputLabel = Just "optional output label"
, sOutputSchemaVarName = "O"
, sOutputSchemaFEELType = "number"
}
}
, sRules =
[ DMNRule
{ sRuleId = "DecisionRule_1"
, sInputEntries =
[ InputEntry
{ sInputEntryId = "UnaryTests_1"
, sMaybeCondition = Just
( XMLText { sText = "1" } )
}
]
, sOutputEntry = OutputEntry
{ sOutputId = "LiteralExpression_2"
, sExpr = XMLText { sText = "10" }
}
}
]
}
}
, Decision
{ sDecId = "P1"
, sDecName = "P1"
, sDecOutVar = DecOutVar
{ sDecVarId = "InformationItem_2"
, sDecVarName = "P1"
, sDecVarFEELType = "number"
}
, sDecTableInfoReqs = []
, sDecTableOrLitExpr = DecTable
{ sDecTableId = "DecisionTable_2"
, sSchema = Schema
{ sInputSchemas = []
, sOutputSchema = OutputSchema
{ sOutputSchemaId = "OutputClause_2"
, sOutputLabel = Just "optional output label"
, sOutputSchemaVarName = "P1"
, sOutputSchemaFEELType = "number"
}
}
, sRules =
[ DMNRule
{ sRuleId = "DecisionRule_2"
, sInputEntries = []
, sOutputEntry = OutputEntry
{ sOutputId = "LiteralExpression_3"
, sExpr = XMLText { sText = "1" }
}
}
]
}
}
]
}
Loading

0 comments on commit ba0576b

Please sign in to comment.