Skip to content

Commit 0b43f8f

Browse files
committed
Remove saw-core parenthesized tuple selector syntax "x.(1)".
With the new tuple representation the distinction between "x.1" and "x.(1)" is no longer needed.
1 parent 84e0573 commit 0b43f8f

File tree

3 files changed

+13
-20
lines changed

3 files changed

+13
-20
lines changed

cryptol-saw-core/saw/Cryptol.sawcore

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ bvExp n x y = foldr Bool (Vec n Bool) n
2222
(reverse n Bool y);
2323

2424
updFst : (a b : sort 0) -> (a -> a) -> #(a, b) -> #(a, b);
25-
updFst a b f x = (f x.(0), x.(1));
25+
updFst a b f x = (f x.0, x.1);
2626

2727
updSnd : (a b : sort 0) -> (b -> b) -> #(a, b) -> #(a, b);
28-
updSnd a b f x = (x.(0), f x.(1));
28+
updSnd a b f x = (x.0, f x.1);
2929

3030
--------------------------------------------------------------------------------
3131
-- Extended natural numbers

saw-core/prelude/Prelude.sawcore

+10-10
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ primitive consTuple : (t : sort 0) -> (ts : TypeList) -> t -> Tuple ts -> Tuple
5252
-- Pair types
5353

5454
fst : (a b : sort 0) -> #(a, b) -> a;
55-
fst a b tup = tup.(0);
55+
fst a b tup = tup.0;
5656

5757
snd : (a b : sort 0) -> #(a, b) -> b;
58-
snd a b tup = tup.(1);
58+
snd a b tup = tup.1;
5959

6060
uncurry (a b c : sort 0) (f : a -> b -> c) : #(a, b) -> c
61-
= (\ (x : #(a, b)) -> f x.(0) x.(1));
61+
= (\ (x : #(a, b)) -> f x.0 x.1);
6262

6363
--------------------------------------------------------------------------------
6464
-- String values
@@ -875,10 +875,10 @@ expNat b e =
875875
primitive divModNat : Nat -> Nat -> #(Nat, Nat);
876876

877877
divNat : Nat -> Nat -> Nat;
878-
divNat x y = (divModNat x y).(0);
878+
divNat x y = (divModNat x y).0;
879879

880880
modNat : Nat -> Nat -> Nat;
881-
modNat x y = (divModNat x y).(1);
881+
modNat x y = (divModNat x y).1;
882882

883883
-- There are implicit constructors from integer literals.
884884

@@ -1504,7 +1504,7 @@ foldList a =
15041504
either #() #(a, List a) (List a)
15051505
(\ (_ : #()) -> Nil a)
15061506
(\ (tup : #(a, List a)) ->
1507-
Cons a tup.(0) tup.(1));
1507+
Cons a tup.0 tup.1);
15081508

15091509
-- A list of types, i.e. `List (sort 0)` if `List` was universe polymorphic
15101510
data ListSort : sort 1
@@ -1563,8 +1563,8 @@ foldW64List =
15631563
(\ (_:#()) -> W64Nil)
15641564
(\ (bv_l : #(Sigma (Vec 64 Bool) (\ (_:Vec 64 Bool) -> #()), W64List)) ->
15651565
W64Cons (Sigma_proj1 (Vec 64 Bool)
1566-
(\ (_:Vec 64 Bool) -> #()) bv_l.(0))
1567-
bv_l.(1));
1566+
(\ (_:Vec 64 Bool) -> #()) bv_l.0)
1567+
bv_l.1);
15681568

15691569

15701570
--------------------------------------------------------------------------------
@@ -2088,7 +2088,7 @@ composeM a b c f g x = bindM b c (f x) g;
20882088
tupleCompMFunBoth : (a b c: sort 0) -> (a -> CompM b) -> #(c, a) -> CompM #(c, b);
20892089
tupleCompMFunBoth a b c f =
20902090
\ (x : #(c, a)) ->
2091-
bindM b #(c, b) (f x.(1)) (\ (y:b) -> returnM #(c, b) (x.(0), y));
2091+
bindM b #(c, b) (f x.1) (\ (y:b) -> returnM #(c, b) (x.0, y));
20922092

20932093
-- Tuple a valu onto the output of a monadic function
20942094
tupleCompMFunOut : (a b c: sort 0) -> c -> (a -> CompM b) -> (a -> CompM #(c, b));
@@ -2454,7 +2454,7 @@ multiFixM : (lrts:LetRecTypes) -> lrtPi lrts (lrtTupleType lrts) ->
24542454
multiArgFixM : (lrt:LetRecType) -> (lrtToType lrt -> lrtToType lrt) ->
24552455
lrtToType lrt;
24562456
multiArgFixM lrt F =
2457-
(multiFixM (LRT_Cons lrt LRT_Nil) (\ (f:lrtToType lrt) -> (F f, ()))).(0);
2457+
(multiFixM (LRT_Cons lrt LRT_Nil) (\ (f:lrtToType lrt) -> (F f, ()))).0;
24582458

24592459

24602460
-- Test computations

saw-core/src/Verifier/SAW/Grammar.y

+1-8
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,12 @@ AtomTerm
181181
| 'isort' nat { Sort (pos $1) (mkSort (tokNat (val $2))) True }
182182
| AtomTerm '.' Ident { RecordProj $1 (val $3) }
183183
| AtomTerm '.' IdentRec {% parseRecursorProj $1 $3 }
184-
| AtomTerm '.' nat {% parseTupleSelector $1 (fmap tokNat $3) }
184+
| AtomTerm '.' nat { mkTupleSelector $1 (tokNat (val $3)) }
185185
| '(' sepBy(Term, ',') ')' { mkTupleValue (pos $1) $2 }
186186
| '#' '(' sepBy(Term, ',') ')' { mkTupleType (pos $1) $3 }
187187
| '[' sepBy(Term, ',') ']' { VecLit (pos $1) $2 }
188188
| '{' sepBy(FieldValue, ',') '}' { RecordValue (pos $1) $2 }
189189
| '#' '{' sepBy(FieldType, ',') '}' { RecordType (pos $1) $3 }
190-
| AtomTerm '.' '(' nat ')' { mkTupleSelector $1 (tokNat (val $4)) }
191190

192191
Ident :: { PosPair Text }
193192
Ident : ident { fmap (Text.pack . tokIdent) $1 }
@@ -343,12 +342,6 @@ parseRecursorProj t _ =
343342
do addParseError (pos t) "Malformed recursor projection"
344343
return (badTerm (pos t))
345344
346-
parseTupleSelector :: Term -> PosPair Natural -> Parser Term
347-
parseTupleSelector t i =
348-
if val i >= 1 then return (mkTupleSelector t (val i)) else
349-
do addParseError (pos t) "non-positive tuple projection index"
350-
return (badTerm (pos t))
351-
352345
-- | Create a module name given a list of strings with the top-most
353346
-- module name given first.
354347
mkPosModuleName :: [PosPair Text] -> PosPair ModuleName

0 commit comments

Comments
 (0)