Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
AVANZINI Martin
ecoimp
Commits
d113d25f
Commit
d113d25f
authored
Nov 18, 2020
by
AVANZINI Martin
Browse files
bExp parser accepts parens
parent
6173cd3f
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/Data/PWhile/BoolExpression.hs
View file @
d113d25f
{-# OPTIONS_GHC -fno-warn-incomplete-patterns #-}
{-# LANGUAGE DeriveTraversable, PatternSynonyms, StandaloneDeriving #-}
{-# LANGUAGE DeriveTraversable, PatternSynonyms,
TypeSynonymInstances,
StandaloneDeriving #-}
module
Data.PWhile.BoolExpression
(
Conj
(
..
)
...
...
src/PWhile/InferEt.hs
View file @
d113d25f
...
...
@@ -194,16 +194,6 @@ normFromBExp :: BExp -> NormTemplate
normFromBExp
b
=
sum
[
normFromExp
(
e1
-
e2
+
1
)
|
e1
:>=:
e2
<-
S
.
toList
(
literals
b
)
]
-- normFromCExp :: C.CExp Rational -> NormTemplate
-- normFromCExp d = sum [ normFromBExp b + norm n
-- | C.GNorm b k n <- varGNorms d
-- , k > 0, not (C.isZeroN n) ]
-- guardNormsFromCExp :: C.CExp Rational -> NormTemplate
-- guardNormsFromCExp d = sum [ normFromBExp d
-- | C.GNorm b k n <- varGNorms d
-- , k > 0, not (C.isZeroN n) ]
substituteM
::
(
C
.
Norm
->
SolveM
NormTemplate
)
->
NormTemplate
->
SolveM
NormTemplate
substituteM
s
=
P
.
fromPolynomialM
s
(
pure
.
P
.
coefficient
)
...
...
@@ -246,7 +236,7 @@ boundedSum (i,f) (l,o) = bs f
PP
.<+>
PP
.
pretty
i
PP
.<+>
PP
.
text
"<="
PP
.<+>
PP
.
pretty
o
))
t
<-
template
"guarded"
(
pure
(
sum
[
nn
*
ng
t
<-
template
"guarded"
(
pure
(
sum
[
nn
*
nn
+
nn
*
ng
|
C
.
GNorm
b
_
n
<-
varGNorms
g
,
let
nn
=
norm
n
,
let
ng
=
sum
[
normFromExp
(
e1
-
e2
+
1
)
...
...
src/PWhile/Parser.hs
View file @
d113d25f
...
...
@@ -96,17 +96,17 @@ withIndent cmb pHead pBody = L.indentBlock whitespaceN p where
pBExp
::
Parser
BExp
pBExp
=
makeExprParser
bTerm
bOperators
where
bTerm
=
do
e1
<-
p
A
Exp
o
p
<-
((
.<=
)
<$
symbol
"<="
)
<|>
((
.>=
)
<$
symbol
"=>"
)
<|>
((
.>=
)
<$
symbol
">="
)
<|>
((
.<
)
<$
symbol
"<"
)
<|>
((
.>
)
<$
symbol
">"
)
<|>
((
.==
)
<$
symbol
"="
)
e2
<-
pAExp
return
$
e1
`
op
`
e2
bTerm
=
try
(
parens
p
B
Exp
)
<|>
(
do
e1
<-
pAEx
p
op
<-
((
.<=
)
<$
symbol
"<="
)
<|>
((
.>=
)
<$
symbol
"=>"
)
<|>
((
.>=
)
<$
symbol
">="
)
<|>
((
.<
)
<$
symbol
"<"
)
<|>
((
.>
)
<$
symbol
">"
)
<|>
((
.==
)
<$
symbol
"="
)
e2
<-
pAExp
return
$
e1
`
op
`
e2
)
bOperators
=
[
[
Prefix
(
neg
<$
keyword
"not"
)
]
,
[
InfixL
((
.&&
)
<$
keyword
"and"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment