Skip to content

Commit f77318a

Browse files
ttuegelMirceaSgithub-actionsrv-jenkins
authored
Fix unparsing built-ins (#2540)
* [WIP]: Use futu for externalizing builtins * implemented new externalization functions * moved externalization code to the test library * Materialize Nix expressions * update kore.cabal * merged master and synched externalisation with unparsing * reverted last two commits * Run fourmolu * addressed PR comments * Format with fourmolu * removed unused import Co-authored-by: MirceaS <[email protected]> Co-authored-by: MirceaS <[email protected]> Co-authored-by: github-actions <[email protected]> Co-authored-by: rv-jenkins <[email protected]>
1 parent e439a42 commit f77318a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+561
-589
lines changed

kore/kore.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ library
261261
Kore.Builtin.Endianness.Endianness
262262
Kore.Builtin.EqTerm
263263
Kore.Builtin.Error
264-
Kore.Builtin.External
265264
Kore.Builtin.Inj
266265
Kore.Builtin.Int
267266
Kore.Builtin.Int.Int
@@ -651,6 +650,7 @@ test-suite kore-test
651650
Test.Kore.Builtin.Definition
652651
Test.Kore.Builtin.Encoding
653652
Test.Kore.Builtin.Endianness
653+
Test.Kore.Builtin.External
654654
Test.Kore.Builtin.Inj
655655
Test.Kore.Builtin.Int
656656
Test.Kore.Builtin.InternalBytes

kore/src/Kore/Builtin.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ module Kore.Builtin (
2828
koreVerifiers,
2929
koreEvaluators,
3030
evaluators,
31-
externalize,
3231
internalize,
3332
) where
3433

@@ -50,7 +49,6 @@ import qualified Kore.Attribute.Symbol as Attribute
5049
import qualified Kore.Builtin.Bool as Bool
5150
import qualified Kore.Builtin.Builtin as Builtin
5251
import qualified Kore.Builtin.Endianness as Endianness
53-
import Kore.Builtin.External
5452
import qualified Kore.Builtin.Inj as Inj
5553
import qualified Kore.Builtin.Int as Int
5654
import qualified Kore.Builtin.InternalBytes as InternalBytes

kore/src/Kore/Builtin/AssocComm/AssocComm.hs

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,19 @@ Copyright : (c) Runtime Verification, 2019
55
License : NCSA
66
-}
77
module Kore.Builtin.AssocComm.AssocComm (
8-
asTermLike,
98
UnitSymbol (..),
109
ConcatSymbol (..),
1110
ConcreteElements (..),
1211
VariableElements (..),
1312
Opaque (..),
1413
) where
1514

16-
import qualified Data.List as List
1715
import Kore.Internal.Symbol (
1816
Symbol,
1917
)
2018
import Kore.Internal.TermLike (
2119
Concrete,
22-
InternalVariable,
2320
TermLike,
24-
mkApplySymbol,
2521
)
2622
import Prelude.Kore
2723

@@ -62,44 +58,3 @@ newtype VariableElements variable = VariableElements {getVariableElements :: [Te
6258

6359
-- | Wrapper for giving names to arguments.
6460
newtype Opaque variable = Opaque {getOpaque :: [TermLike variable]}
65-
66-
-- | Externalizes a 'Domain.InternalAc' as a 'TermLike'.
67-
asTermLike ::
68-
forall variable.
69-
InternalVariable variable =>
70-
UnitSymbol ->
71-
ConcatSymbol ->
72-
ConcreteElements variable ->
73-
VariableElements variable ->
74-
Opaque variable ->
75-
TermLike variable
76-
asTermLike
77-
(UnitSymbol unitSymbol)
78-
(ConcatSymbol concatSymbol)
79-
(ConcreteElements concreteElements)
80-
(VariableElements variableElements)
81-
(Opaque opaque) =
82-
case splitLastInit concreteElements of
83-
Nothing -> case splitLastInit opaque of
84-
Nothing -> case splitLastInit variableElements of
85-
Nothing -> mkApplySymbol unitSymbol []
86-
Just (ves, ve) -> addTerms ves ve
87-
Just (opaqs, opaq) ->
88-
addTerms variableElements (addTerms opaqs opaq)
89-
Just (concretes, concrete) ->
90-
addTerms variableElements $
91-
addTerms opaque $
92-
addTerms concretes concrete
93-
where
94-
addTerms :: [TermLike variable] -> TermLike variable -> TermLike variable
95-
addTerms terms term = List.foldr concat' term terms
96-
97-
concat' :: TermLike variable -> TermLike variable -> TermLike variable
98-
concat' map1 map2 = mkApplySymbol concatSymbol [map1, map2]
99-
100-
splitLastInit :: [a] -> Maybe ([a], a)
101-
splitLastInit [] = Nothing
102-
splitLastInit [a] = Just ([], a)
103-
splitLastInit (a : as) = do
104-
(initA, lastA) <- splitLastInit as
105-
return (a : initA, lastA)

kore/src/Kore/Builtin/AssociativeCommutative.hs

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ builtin modules.
1919
module Kore.Builtin.AssociativeCommutative (
2020
asInternalConcrete,
2121
asPattern,
22-
asTermLike,
2322
ConcatSymbol (..),
2423
ConcreteElements (..),
2524
evalConcatNormalizedOrBottom,
@@ -97,7 +96,6 @@ import Kore.Internal.Symbol (
9796
import Kore.Internal.TermLike (
9897
Key,
9998
TermLike,
100-
mkApplySymbol,
10199
mkElemVar,
102100
termLikeSort,
103101
pattern App_,
@@ -1623,44 +1621,3 @@ newtype VariableElements variable = VariableElements {getVariableElements :: [Te
16231621

16241622
-- | Wrapper for giving names to arguments.
16251623
newtype Opaque variable = Opaque {getOpaque :: [TermLike variable]}
1626-
1627-
-- | Externalizes a 'InternalAc' as a 'TermLike'.
1628-
asTermLike ::
1629-
forall variable.
1630-
InternalVariable variable =>
1631-
UnitSymbol ->
1632-
ConcatSymbol ->
1633-
ConcreteElements variable ->
1634-
VariableElements variable ->
1635-
Opaque variable ->
1636-
TermLike variable
1637-
asTermLike
1638-
(UnitSymbol unitSymbol)
1639-
(ConcatSymbol concatSymbol)
1640-
(ConcreteElements concreteElements)
1641-
(VariableElements variableElements)
1642-
(Opaque opaque) =
1643-
case splitLastInit concreteElements of
1644-
Nothing -> case splitLastInit opaque of
1645-
Nothing -> case splitLastInit variableElements of
1646-
Nothing -> mkApplySymbol unitSymbol []
1647-
Just (ves, ve) -> addTerms ves ve
1648-
Just (opaqs, opaq) ->
1649-
addTerms variableElements (addTerms opaqs opaq)
1650-
Just (concretes, concrete) ->
1651-
addTerms variableElements $
1652-
addTerms opaque $
1653-
addTerms concretes concrete
1654-
where
1655-
addTerms :: [TermLike variable] -> TermLike variable -> TermLike variable
1656-
addTerms terms term = List.foldr concat' term terms
1657-
1658-
concat' :: TermLike variable -> TermLike variable -> TermLike variable
1659-
concat' map1 map2 = mkApplySymbol concatSymbol [map1, map2]
1660-
1661-
splitLastInit :: [a] -> Maybe ([a], a)
1662-
splitLastInit [] = Nothing
1663-
splitLastInit [a] = Just ([], a)
1664-
splitLastInit (a : as) = do
1665-
(initA, lastA) <- splitLastInit as
1666-
return (a : initA, lastA)

kore/src/Kore/Builtin/Bool.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ module Kore.Builtin.Bool (
88
verifiers,
99
builtinFunctions,
1010
asInternal,
11-
asTermLike,
1211
asPattern,
1312
extractBoolDomainValue,
1413
parse,

kore/src/Kore/Builtin/Bool/Bool.hs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ module Kore.Builtin.Bool.Bool (
66
sort,
77
asBuiltin,
88
asInternal,
9-
asTermLike,
109
asPattern,
1110

1211
-- * Keys
@@ -35,18 +34,14 @@ import qualified Kore.Internal.Pattern as Pattern (
3534
fromTermLike,
3635
)
3736
import Kore.Internal.TermLike (
38-
DomainValue (DomainValue),
3937
InternalVariable,
4038
Sort,
4139
TermLike,
42-
mkDomainValue,
4340
mkInternalBool,
44-
mkStringLiteral,
4541
)
4642
import qualified Kore.Internal.TermLike as TermLike (
4743
markSimplified,
4844
)
49-
import qualified Kore.Internal.TermLike as TermLike.DoNotUse
5045
import Prelude.Kore
5146

5247
-- | Builtin name of the @Bool@ sort.
@@ -79,31 +74,6 @@ asBuiltin ::
7974
InternalBool
8075
asBuiltin = InternalBool
8176

82-
{- | Render a 'Bool' as a domain value pattern of the given sort.
83-
84-
The result sort should be hooked to the builtin @Bool@ sort, but this is not
85-
checked.
86-
87-
See also: 'sort'
88-
-}
89-
asTermLike ::
90-
InternalVariable variable =>
91-
-- | builtin value to render
92-
InternalBool ->
93-
TermLike variable
94-
asTermLike builtin =
95-
mkDomainValue
96-
DomainValue
97-
{ domainValueSort = internalBoolSort
98-
, domainValueChild = mkStringLiteral literal
99-
}
100-
where
101-
InternalBool{internalBoolSort} = builtin
102-
InternalBool{internalBoolValue = bool} = builtin
103-
literal
104-
| bool = "true"
105-
| otherwise = "false"
106-
10777
asPattern ::
10878
InternalVariable variable =>
10979
-- | resulting sort

kore/src/Kore/Builtin/External.hs

Lines changed: 0 additions & 135 deletions
This file was deleted.

kore/src/Kore/Builtin/Int.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ module Kore.Builtin.Int (
2323
builtinFunctions,
2424
expectBuiltinInt,
2525
extractIntDomainValue,
26-
asTermLike,
2726
asInternal,
2827
asPattern,
2928
asPartialPattern,

0 commit comments

Comments
 (0)