|
definition: |
translate :: PM [Statement] -> Bool -> String -> Pos -> PM String
translate (PM (WM (Errors err) ws)) _ _ _ = PM $ WM (throwPR err) ws
translate (PM (WM (OK stats) ws)) withrundb mModel pos =
let (PM (WM resPR warns)) = sequencePM (map (transStatement pos mModel) stats)
in liftPM showFunction (PM $ WM resPR (warns++ws))
where
-- The list of CExpr representing the statements is concatenated and pretty
-- printed. To obtain a single-line translation, line feeds are replaced by
-- space characters and indentation is removed
showFunction stats0 =
let finExpr = if withrundb
then applyF (mCDBI, "runWithDB")
[constF (mModel, "sqliteDBFile"),
concatStatements stats0]
else concatStatements stats0
finStr = (pPrint (ppCExpr defaultOptions finExpr))
newLines = splitOn ['\n'] finStr
in '(' : removeIndents (intercalate [' '] newLines) ++ ")"
|
|
demand: |
argument 1 |
|
deterministic: |
deterministic operation |
|
documentation: |
Invokes the translation of the AST into a string of curry code in case a valid AST is given, does nothing otherwise. |
|
failfree: |
<FAILING> |
|
indeterministic: |
referentially transparent operation |
|
infix: |
no fixity defined |
|
iotype: |
{({PM},_,_,_) |-> _}
|
|
name: |
translate |
|
precedence: |
no precedence defined |
|
result-values: |
_ |
|
signature: |
CPP.ICode.ParseMonad.PM [CPP.ICode.Parser.SQL.AST.Statement] -> Prelude.Bool -> String -> CPP.ICode.ParsePos.Pos -> CPP.ICode.ParseMonad.PM String |
|
solution-complete: |
operation might suspend on free variables |
|
terminating: |
possibly non-terminating |
|
totally-defined: |
possibly non-reducible on same data term |