Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
J
javawlp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
impresshs
javawlp
Commits
ddecb118
Verified
Commit
ddecb118
authored
7 years ago
by
Ogilvie, D.H. (Duncan)
Browse files
Options
Downloads
Patches
Plain Diff
initial implementation of LogicIR.Backend.Pretty
parent
31b77bd3
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/LogicIR/Backend/Pretty.hs
+61
-0
61 additions, 0 deletions
src/LogicIR/Backend/Pretty.hs
src/SimpleFormulaChecker.hs
+3
-1
3 additions, 1 deletion
src/SimpleFormulaChecker.hs
with
64 additions
and
1 deletion
src/LogicIR/Backend/Pretty.hs
0 → 100644
+
61
−
0
View file @
ddecb118
module
LogicIR.Backend.Pretty
(
prettyLExpr
)
where
import
Data.List
import
LogicIR.Expr
import
LogicIR.Fold
prettyLExpr
::
LExpr
->
String
prettyLExpr
=
foldLExpr
prettyLExprAlgebra
prettyType
::
Type
->
String
prettyType
(
TPrim
PInt
)
=
"int"
prettyType
(
TPrim
PBool
)
=
"bool"
prettyType
(
TArray
t
)
=
prettyType
t
++
"[]"
prettyCOp
::
COp
->
String
prettyCOp
CEqual
=
"=="
prettyCOp
CNEqual
=
"!="
prettyCOp
CLess
=
"<"
prettyCOp
CGreater
=
">"
prettyCOp
CLeq
=
"<="
prettyCOp
CGeq
=
">="
prettyLBinop
::
LBinop
->
String
prettyLBinop
LAnd
=
"&&"
prettyLBinop
LOr
=
"||"
prettyLBinop
LImpl
=
"=>"
prettyLBinop
LBicond
=
"<=>"
prettyNBinop
::
NBinop
->
String
prettyNBinop
NAdd
=
"+"
prettyNBinop
NSub
=
"-"
prettyNBinop
NMul
=
"*"
prettyNBinop
NDiv
=
"/"
prettyNBinop
NRem
=
"%"
prettyNBinop
NShl
=
">>"
prettyNBinop
NShr
=
"<<"
prettyNBinop
NAnd
=
"&"
prettyNBinop
NOr
=
"|"
prettyNBinop
NXor
=
"^"
prettyNUnop
::
NUnop
->
String
prettyNUnop
NNeg
=
"-"
prettyNUnop
NNot
=
"~"
prettyVar
::
Var
->
String
prettyVar
(
Var
t
n
)
=
'('
:
prettyType
t
++
")"
++
n
prettyLExprAlgebra
::
LExprAlgebra
String
prettyLExprAlgebra
=
(
flConst
,
prettyVar
,
flNot
,
flBinop
,
flComp
,
flQuant
,
flArray
,
fnConst
,
prettyVar
,
fnUnop
,
fnBinop
,
fnArray
,
fnIf
)
where
flConst
b
=
if
b
then
"true"
else
"false"
flNot
a
=
'!'
:
a
flBinop
a
o
b
=
a
++
" "
++
prettyLBinop
o
++
" "
++
b
flComp
a
o
b
=
a
++
" "
++
prettyCOp
o
++
" "
++
b
flQuant
o
vs
a
=
'('
:
show
o
++
intercalate
","
(
map
prettyVar
vs
)
++
": "
++
a
++
")"
flArray
v
[
a
]
=
prettyVar
v
++
"["
++
(
foldLExpr
prettyLExprAlgebra
a
)
++
"]"
fnConst
n
=
show
n
fnUnop
o
a
=
prettyNUnop
o
++
a
fnBinop
a
o
b
=
a
++
" "
++
prettyNBinop
o
++
" "
++
b
fnArray
=
flArray
fnIf
c
a
b
=
"("
++
c
++
") ? ("
++
a
++
") : ("
++
b
++
")"
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/SimpleFormulaChecker.hs
+
3
−
1
View file @
ddecb118
...
...
@@ -13,6 +13,7 @@ import Javawlp.Engine.Verifier
import
LogicIR.Expr
import
LogicIR.Frontend.Java
import
LogicIR.Backend.Z3
import
LogicIR.Backend.Pretty
import
Debug.Trace
...
...
@@ -111,7 +112,8 @@ determineFormulaEq m1@(decls1, mbody1, env1) m2@(decls2, mbody2, env2) name = do
-- get preconditions
let
(
e1
,
e2
)
=
(
extractCond
m1
name
,
extractCond
m2
name
)
putStrLn
$
"e1:
\n
"
++
prettyPrint
e1
++
"
\n\n
e2:
\n
"
++
prettyPrint
e2
++
"
\n
"
putStrLn
$
show
$
javaExpToLExpr
e1
env1
decls1
let
lexpr
=
javaExpToLExpr
e1
env1
decls1
putStrLn
$
show
lexpr
++
"
\n\n
"
++
prettyLExpr
lexpr
{--- get postconditions
let (post1, post2) = (extractCond m1 "post", extractCond m2 "post")
putStrLn $ "post1:\n" ++ prettyPrint post1 ++ "\npost2:\n" ++ prettyPrint post2 ++ "\n"-}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment