diff --git a/executable_semantics/syntax/parser.ypp b/executable_semantics/syntax/parser.ypp index 2ed74be3cb88..816849ffcfd4 100644 --- a/executable_semantics/syntax/parser.ypp +++ b/executable_semantics/syntax/parser.ypp @@ -104,6 +104,7 @@ void yy::parser::error( %type return_type %type paren_expression %type tuple +%type var_compatible_expression %type variable_declaration %type member %type *> member_list @@ -164,7 +165,7 @@ void yy::parser::error( ; %precedence "{" "}" -%precedence ":" "," DBLARROW +%precedence "," DBLARROW %left OR AND %nonassoc EQUAL_EQUAL %left "+" "-" @@ -183,31 +184,10 @@ pattern: { $$ = $1; } ; expression: - identifier - { $$ = Carbon::Expression::MakeVar(yylineno, $1); } -| expression designator - { $$ = Carbon::Expression::MakeGetField(yylineno, $1, $2); } -| expression "[" expression "]" - { $$ = Carbon::Expression::MakeIndex(yylineno, $1, $3); } -| expression ":" identifier - { $$ = Carbon::Expression::MakeVarPat(yylineno, $3, $1); } -| integer_literal - { $$ = Carbon::Expression::MakeInt(yylineno, $1); } -| TRUE - { $$ = Carbon::Expression::MakeBool(yylineno, true); } -| FALSE - { $$ = Carbon::Expression::MakeBool(yylineno, false); } -| INT - { $$ = Carbon::Expression::MakeIntType(yylineno); } -| BOOL - { $$ = Carbon::Expression::MakeBoolType(yylineno); } -| TYPE - { $$ = Carbon::Expression::MakeTypeType(yylineno); } -| AUTO - { $$ = Carbon::Expression::MakeAutoType(yylineno); } -| CONTINUATION_TYPE - { $$ = Carbon::Expression::MakeContinuationType(yylineno); } -| paren_expression { $$ = $1; } + var_compatible_expression + { $$ = $1; } +| var_compatible_expression identifier + { $$ = Carbon::Expression::MakeVarPat(yylineno, $2, $1); } | expression EQUAL_EQUAL expression { $$ = Carbon::Expression::MakeBinOp(yylineno, Carbon::Operator::Eq, $1, $3); } | expression "+" expression @@ -222,11 +202,39 @@ expression: { $$ = Carbon::Expression::MakeUnOp(yylineno, Carbon::Operator::Not, $2); } | "-" expression %prec UNARY_MINUS { $$ = Carbon::Expression::MakeUnOp(yylineno, Carbon::Operator::Neg, $2); } -| expression tuple - { $$ = Carbon::Expression::MakeCall(yylineno, $1, $2); } | FNTY tuple return_type { $$ = Carbon::Expression::MakeFunType(yylineno, $2, $3); } ; +// This is the subset of `expression` which can act as the type part of a +// variable declaration without creating ambiguity. +var_compatible_expression: + paren_expression + { $$ = $1; } +| identifier + { $$ = Carbon::Expression::MakeVar(yylineno, $1); } +| TRUE + { $$ = Carbon::Expression::MakeBool(yylineno, true); } +| FALSE + { $$ = Carbon::Expression::MakeBool(yylineno, false); } +| INT + { $$ = Carbon::Expression::MakeIntType(yylineno); } +| BOOL + { $$ = Carbon::Expression::MakeBoolType(yylineno); } +| TYPE + { $$ = Carbon::Expression::MakeTypeType(yylineno); } +| AUTO + { $$ = Carbon::Expression::MakeAutoType(yylineno); } +| CONTINUATION_TYPE + { $$ = Carbon::Expression::MakeContinuationType(yylineno); } +| integer_literal + { $$ = Carbon::Expression::MakeInt(yylineno, $1); } +| expression designator + { $$ = Carbon::Expression::MakeGetField(yylineno, $1, $2); } +| expression "[" expression "]" + { $$ = Carbon::Expression::MakeIndex(yylineno, $1, $3); } +| expression tuple + { $$ = Carbon::Expression::MakeCall(yylineno, $1, $2); } +; designator: "." identifier { $$ = $2; } ; paren_expression: "(" paren_contents ")" @@ -340,8 +348,8 @@ function_declaration: FN identifier tuple return_type ";" { $$ = MakeFunDef(yylineno, $2, $4, $3, 0); } ; -variable_declaration: expression ":" identifier - { $$ = MakeField(yylineno, $3, $1); } +variable_declaration: var_compatible_expression identifier + { $$ = MakeField(yylineno, $2, $1); } ; member: VAR variable_declaration ";" { $$ = $2; } diff --git a/executable_semantics/testdata/assignment_copy1.6c b/executable_semantics/testdata/assignment_copy1.6c index a6311cb5d1d9..99bcc2fea169 100644 --- a/executable_semantics/testdata/assignment_copy1.6c +++ b/executable_semantics/testdata/assignment_copy1.6c @@ -5,9 +5,9 @@ // Test that assignment performs a copy and does not create an alias. fn main() -> Int { - var Int: x = -1; + var Int x = -1; { - var Int: y = 0; + var Int y = 0; x = y; // y dies here } diff --git a/executable_semantics/testdata/assignment_copy2.6c b/executable_semantics/testdata/assignment_copy2.6c index c991b955511b..743e0f345e90 100644 --- a/executable_semantics/testdata/assignment_copy2.6c +++ b/executable_semantics/testdata/assignment_copy2.6c @@ -5,8 +5,8 @@ // Test that assignment performs a copy and does not create an alias. fn main() -> Int { - var Int: x = 0; - var Int: y = x; + var Int x = 0; + var Int y = x; x = 1; return y; } diff --git a/executable_semantics/testdata/block1.6c b/executable_semantics/testdata/block1.6c index 7c6005123971..58a7d0f72983 100644 --- a/executable_semantics/testdata/block1.6c +++ b/executable_semantics/testdata/block1.6c @@ -3,9 +3,9 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception fn main() -> Int { - var Int: x = 0; + var Int x = 0; { - var Int: x = 1; + var Int x = 1; } return x; } diff --git a/executable_semantics/testdata/block2.6c b/executable_semantics/testdata/block2.6c index e985e9070254..e35feff88ef2 100644 --- a/executable_semantics/testdata/block2.6c +++ b/executable_semantics/testdata/block2.6c @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception fn main() -> Int { - var Int: x = 0; + var Int x = 0; { // empty block } diff --git a/executable_semantics/testdata/break1.6c b/executable_semantics/testdata/break1.6c index 126336e210a8..1044a7ed48f6 100644 --- a/executable_semantics/testdata/break1.6c +++ b/executable_semantics/testdata/break1.6c @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception fn main() -> Int { - var Int: x = 2; + var Int x = 2; while (true) { if (x == 0) break; diff --git a/executable_semantics/testdata/choice1.6c b/executable_semantics/testdata/choice1.6c index 859dd9312733..d891b5d9c4b1 100644 --- a/executable_semantics/testdata/choice1.6c +++ b/executable_semantics/testdata/choice1.6c @@ -9,23 +9,23 @@ choice Ints { } fn main() -> Int { - var auto: x = Ints.None(); - var auto: y = Ints.One(42); - var auto: n = 0; + var auto x = Ints.None(); + var auto y = Ints.One(42); + var auto n = 0; match (y) { case Ints.None => n = n + 2; - case Ints.One(auto: x) => + case Ints.One(auto x) => n = x + 1 - 42; - case Ints.Two(auto: a, auto: b) => + case Ints.Two(auto a, auto b) => n = 2; } match (x) { - case Ints.One(auto: x) => + case Ints.One(auto x) => n = x + 2; case Ints.None() => n = n - 1; - case Ints.Two(auto: x, auto: y) => + case Ints.Two(auto x, auto y) => n = 5; } return n; diff --git a/executable_semantics/testdata/continue1.6c b/executable_semantics/testdata/continue1.6c index 7eefc430a27b..16d426ef8573 100644 --- a/executable_semantics/testdata/continue1.6c +++ b/executable_semantics/testdata/continue1.6c @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception fn main() -> Int { - var auto: x = 2; + var auto x = 2; while (not (x == 0)) { x = x - 1; continue; diff --git a/executable_semantics/testdata/experimental_continuation1.6c b/executable_semantics/testdata/experimental_continuation1.6c index bb1753a3ed2a..820657c3caf4 100644 --- a/executable_semantics/testdata/experimental_continuation1.6c +++ b/executable_semantics/testdata/experimental_continuation1.6c @@ -5,7 +5,7 @@ // Test that creating a continuation doesn't do anything. fn main() -> Int { - var Int: x = 0; + var Int x = 0; __continuation k { x = x + 1; } diff --git a/executable_semantics/testdata/experimental_continuation2.6c b/executable_semantics/testdata/experimental_continuation2.6c index e67ad641c003..97cb0384ecf1 100644 --- a/executable_semantics/testdata/experimental_continuation2.6c +++ b/executable_semantics/testdata/experimental_continuation2.6c @@ -5,7 +5,7 @@ // Test creating and running a continuation. fn main() -> Int { - var Int: x = 0; + var Int x = 0; __continuation k { x = x + 1; } diff --git a/executable_semantics/testdata/experimental_continuation3.6c b/executable_semantics/testdata/experimental_continuation3.6c index 5dbf98af058a..07dae48536d1 100644 --- a/executable_semantics/testdata/experimental_continuation3.6c +++ b/executable_semantics/testdata/experimental_continuation3.6c @@ -6,7 +6,7 @@ // `__run`. fn main() -> Int { - var Int: x = 0; + var Int x = 0; __continuation k { x = x + 1; __await; diff --git a/executable_semantics/testdata/experimental_continuation4.6c b/executable_semantics/testdata/experimental_continuation4.6c index 32fffb80dded..86c527a41906 100644 --- a/executable_semantics/testdata/experimental_continuation4.6c +++ b/executable_semantics/testdata/experimental_continuation4.6c @@ -6,13 +6,13 @@ // continuation as `k1`. fn main() -> Int { - var Int: x = 0; + var Int x = 0; __continuation k1 { x = x + 1; __await; x = x + 2; } - var __Continuation: k2 = k1; + var __Continuation k2 = k1; __run k1; __run k2; return x; diff --git a/executable_semantics/testdata/experimental_continuation5.6c b/executable_semantics/testdata/experimental_continuation5.6c index ceb905d3796b..efd5170afb5a 100644 --- a/executable_semantics/testdata/experimental_continuation5.6c +++ b/executable_semantics/testdata/experimental_continuation5.6c @@ -5,9 +5,9 @@ // Test access to block-scoped variables upon resuming a continuation. fn main() -> Int { - var Int: y = 0; + var Int y = 0; __continuation k { - var Int: x = 0; + var Int x = 0; x = x + 1; __await; x = x + 2; diff --git a/executable_semantics/testdata/experimental_continuation6.6c b/executable_semantics/testdata/experimental_continuation6.6c index 77299a799843..5d73161c6905 100644 --- a/executable_semantics/testdata/experimental_continuation6.6c +++ b/executable_semantics/testdata/experimental_continuation6.6c @@ -4,9 +4,9 @@ // Test recursive functions inside continuations. -var Int: current = 0; +var Int current = 0; -fn CountUpTo(Int: x) -> Int { +fn CountUpTo(Int x) -> Int { if (x == 0) { current = 0; __await; @@ -22,8 +22,8 @@ fn main() -> Int { __continuation k { CountUpTo(5); } - var Int: sum = 0; - var Int: count = 5; + var Int sum = 0; + var Int count = 5; while (not (count == 0)) { __run k; sum = sum + current; diff --git a/executable_semantics/testdata/experimental_continuation7.6c b/executable_semantics/testdata/experimental_continuation7.6c index 90c0aae2b4e8..f60dfaa493f3 100644 --- a/executable_semantics/testdata/experimental_continuation7.6c +++ b/executable_semantics/testdata/experimental_continuation7.6c @@ -6,18 +6,18 @@ // on the stack such as the variable `x`. In this example the copy // happens after the variable `x` is created. -var Int: y = 0; +var Int y = 0; fn main() -> Int { __continuation k1 { - var Int: x = 0; + var Int x = 0; x = x + 1; __await; x = x + 2; y = x; } __run k1; - var __Continuation: k2 = k1; + var __Continuation k2 = k1; __run k2; return y; } diff --git a/executable_semantics/testdata/experimental_continuation8.6c b/executable_semantics/testdata/experimental_continuation8.6c index fcad4d8278a8..5a24b7fbf81c 100644 --- a/executable_semantics/testdata/experimental_continuation8.6c +++ b/executable_semantics/testdata/experimental_continuation8.6c @@ -7,16 +7,16 @@ // happens before the variable `x` is created, so each continuation // creates a different `x`. -var Int: y = 0; +var Int y = 0; fn main() -> Int { __continuation k1 { - var Int: x = 0; + var Int x = 0; x = x + 1; __await; y = x; } - var __Continuation: k2 = k1; + var __Continuation k2 = k1; __run k1; __run k2; __run k1; diff --git a/executable_semantics/testdata/experimental_continuation9.6c b/executable_semantics/testdata/experimental_continuation9.6c index 3a6639cd10c1..2dbfafbb21b4 100644 --- a/executable_semantics/testdata/experimental_continuation9.6c +++ b/executable_semantics/testdata/experimental_continuation9.6c @@ -7,15 +7,15 @@ // is dangerous and can happen inside continuations. fn capture() -> __Continuation { - var Int: x = 1; + var Int x = 1; __continuation k { - var Int: y = x; + var Int y = x; } return k; } fn main() -> Int { - var __Continuation: k = capture(); + var __Continuation k = capture(); __run k; // error, lifetime of x is over return 0; } diff --git a/executable_semantics/testdata/fun1.6c b/executable_semantics/testdata/fun1.6c index f7ccc5ba83cd..898f97307a9f 100644 --- a/executable_semantics/testdata/fun1.6c +++ b/executable_semantics/testdata/fun1.6c @@ -2,7 +2,7 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -fn f(Int: x) -> Int { +fn f(Int x) -> Int { return x - 1; } diff --git a/executable_semantics/testdata/fun2.6c b/executable_semantics/testdata/fun2.6c index 8ea4f49fe4a0..2cfe78aae153 100644 --- a/executable_semantics/testdata/fun2.6c +++ b/executable_semantics/testdata/fun2.6c @@ -6,12 +6,12 @@ // This makes sure that when the value in `x` dies, // it does not cause the value in `a` to also die. -fn f(Int: x) -> Int { +fn f(Int x) -> Int { return 0; } fn main() -> Int { - var Int: a = 0; var Int: b = 1; + var Int a = 0; var Int b = 1; f(a); b = a; return b; diff --git a/executable_semantics/testdata/fun3.6c b/executable_semantics/testdata/fun3.6c index 8cb0d9b5a34e..62a43dfffab2 100644 --- a/executable_semantics/testdata/fun3.6c +++ b/executable_semantics/testdata/fun3.6c @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // Test multiple arguments -fn f(Int: x, Int: y) -> Int { +fn f(Int x, Int y) -> Int { return x + y; } diff --git a/executable_semantics/testdata/fun5.6c b/executable_semantics/testdata/fun5.6c index 85c525728ebb..c73ebbf8a653 100644 --- a/executable_semantics/testdata/fun5.6c +++ b/executable_semantics/testdata/fun5.6c @@ -2,7 +2,7 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -fn add(Int: x, Int: y) => x + y; +fn add(Int x, Int y) => x + y; fn main() -> Int { return add(1, 2) - 3; diff --git a/executable_semantics/testdata/fun6_fail_type.6c b/executable_semantics/testdata/fun6_fail_type.6c index b10a2c1537f0..96e064d839a4 100644 --- a/executable_semantics/testdata/fun6_fail_type.6c +++ b/executable_semantics/testdata/fun6_fail_type.6c @@ -2,10 +2,10 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -fn f(Int: x, Int: y) -> Int { return x + y; } +fn f(Int x, Int y) -> Int { return x + y; } fn main() -> Int { - var (Int, Int): xy = (1, 2); + var (Int, Int) xy = (1, 2); // should fail to type-check return f(xy); } diff --git a/executable_semantics/testdata/fun_named_params.6c b/executable_semantics/testdata/fun_named_params.6c index 727741385536..00b918174b86 100644 --- a/executable_semantics/testdata/fun_named_params.6c +++ b/executable_semantics/testdata/fun_named_params.6c @@ -2,7 +2,7 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -fn f(Int: x, .d = Int: y) => x + y; +fn f(Int x, .d = Int y) => x + y; fn main() -> Int { return f(1, .d = 2) - 3; diff --git a/executable_semantics/testdata/fun_named_params2.6c b/executable_semantics/testdata/fun_named_params2.6c index 7aba92ccf5c1..a19e2aa56b37 100644 --- a/executable_semantics/testdata/fun_named_params2.6c +++ b/executable_semantics/testdata/fun_named_params2.6c @@ -2,7 +2,7 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -fn f(Int: x, .d = Int: y, Int: z, .e = Int: a) => (x + y) - (z + a); +fn f(Int x, .d = Int y, Int z, .e = Int a) => (x + y) - (z + a); fn main() -> Int { return 0; diff --git a/executable_semantics/testdata/fun_recur.6c b/executable_semantics/testdata/fun_recur.6c index b53060275b2f..6b1f728199e9 100644 --- a/executable_semantics/testdata/fun_recur.6c +++ b/executable_semantics/testdata/fun_recur.6c @@ -2,7 +2,7 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -fn f(Int: x) -> Int { +fn f(Int x) -> Int { if (x == 0) return x; else diff --git a/executable_semantics/testdata/funptr1.6c b/executable_semantics/testdata/funptr1.6c index 114ace63fb3d..a661e3267375 100644 --- a/executable_semantics/testdata/funptr1.6c +++ b/executable_semantics/testdata/funptr1.6c @@ -2,11 +2,11 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -fn add1(Int: x) -> Int { +fn add1(Int x) -> Int { return x + 1; } fn main() -> Int { - var fnty(Int)->Int: f = add1; + var (fnty(Int)->Int) f = add1; return f(-1); } diff --git a/executable_semantics/testdata/global_variable1.6c b/executable_semantics/testdata/global_variable1.6c index 3ad1fdd5409e..fac426d7b143 100644 --- a/executable_semantics/testdata/global_variable1.6c +++ b/executable_semantics/testdata/global_variable1.6c @@ -4,7 +4,7 @@ // Test global variable initialization and read. -var Int: zero = 0; +var Int zero = 0; fn main() -> Int { return zero; diff --git a/executable_semantics/testdata/global_variable2.6c b/executable_semantics/testdata/global_variable2.6c index 166d6d9dc47b..7feeefa6442f 100644 --- a/executable_semantics/testdata/global_variable2.6c +++ b/executable_semantics/testdata/global_variable2.6c @@ -5,7 +5,7 @@ // Test that mutations to a global variable in one function is visible // in another function. -var Int: flag = 1; +var Int flag = 1; fn flipFlag() -> () { flag = 0; diff --git a/executable_semantics/testdata/global_variable3.6c b/executable_semantics/testdata/global_variable3.6c index 1c5f99a89dfb..7a8bd2510a91 100644 --- a/executable_semantics/testdata/global_variable3.6c +++ b/executable_semantics/testdata/global_variable3.6c @@ -4,7 +4,7 @@ // Test type checking of global variable. Error expected. -var Int: flag = true; +var Int flag = true; fn main() -> Int { return 0; diff --git a/executable_semantics/testdata/global_variable4.6c b/executable_semantics/testdata/global_variable4.6c index 762d4971e318..413c5b3bb884 100644 --- a/executable_semantics/testdata/global_variable4.6c +++ b/executable_semantics/testdata/global_variable4.6c @@ -4,7 +4,7 @@ // Test mutation of a global variable. -var Int: zero = 1; +var Int zero = 1; fn main() -> Int { zero = 0; diff --git a/executable_semantics/testdata/global_variable5.6c b/executable_semantics/testdata/global_variable5.6c index e2b86f83cd2e..b1c530544e1f 100644 --- a/executable_semantics/testdata/global_variable5.6c +++ b/executable_semantics/testdata/global_variable5.6c @@ -4,9 +4,9 @@ // Test overshadowing of global variable. -var Int: x = 1; +var Int x = 1; -fn identity(Int: x) { +fn identity(Int x) { return x; } diff --git a/executable_semantics/testdata/global_variable6.6c b/executable_semantics/testdata/global_variable6.6c index 3a48b6976873..cac345c33830 100644 --- a/executable_semantics/testdata/global_variable6.6c +++ b/executable_semantics/testdata/global_variable6.6c @@ -4,9 +4,9 @@ // Test a global variable depending on another global. -var Int: x = 0; +var Int x = 0; -var Int: y = x; +var Int y = x; fn main() -> Int { return y; diff --git a/executable_semantics/testdata/global_variable7.6c b/executable_semantics/testdata/global_variable7.6c index a6bb8eeb341e..50fdc00759ff 100644 --- a/executable_semantics/testdata/global_variable7.6c +++ b/executable_semantics/testdata/global_variable7.6c @@ -8,7 +8,7 @@ fn f() -> Int { return 0; } -var Int: y = f(); +var Int y = f(); fn main() -> Int { return y; diff --git a/executable_semantics/testdata/global_variable8.6c b/executable_semantics/testdata/global_variable8.6c index 41bf398067c5..d2cffe05e18e 100644 --- a/executable_semantics/testdata/global_variable8.6c +++ b/executable_semantics/testdata/global_variable8.6c @@ -5,9 +5,9 @@ // Test that a global variable may not depend on a later global. // Error expected. -var Int: x = y; +var Int x = y; -var Int: y = 0; +var Int y = 0; fn main() -> Int { return x; diff --git a/executable_semantics/testdata/match_any_int.6c b/executable_semantics/testdata/match_any_int.6c index 7de6e3017bc5..f0ca73980975 100644 --- a/executable_semantics/testdata/match_any_int.6c +++ b/executable_semantics/testdata/match_any_int.6c @@ -3,9 +3,9 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception fn main() -> Int { - var auto: t = 5; + var auto t = 5; match (t) { - case Int: x => + case Int x => return x - 5; } } diff --git a/executable_semantics/testdata/match_int.6c b/executable_semantics/testdata/match_int.6c index 6e809eb27a9a..6c8ce83110af 100644 --- a/executable_semantics/testdata/match_int.6c +++ b/executable_semantics/testdata/match_int.6c @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception fn main() -> Int { - var auto: t = 5; + var auto t = 5; match (t) { case 5 => return 0; diff --git a/executable_semantics/testdata/match_int_default.6c b/executable_semantics/testdata/match_int_default.6c index 62f61775940a..227477b17924 100644 --- a/executable_semantics/testdata/match_int_default.6c +++ b/executable_semantics/testdata/match_int_default.6c @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception fn main() -> Int { - var auto: t = 5; + var auto t = 5; match (t) { case 3 => return -1; diff --git a/executable_semantics/testdata/match_type.6c b/executable_semantics/testdata/match_type.6c index 324d81d3013d..fafbcff6899e 100644 --- a/executable_semantics/testdata/match_type.6c +++ b/executable_semantics/testdata/match_type.6c @@ -3,14 +3,14 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception fn main() -> Int { - var auto: t = fnty (Int,Int); - var Int: x = 0; + var auto t = fnty (Int,Int); + var Int x = 0; match (t) { - case Type: z => + case Type z => x = x + 1; } match (t) { - case fnty(Type: a,Type: b) => + case fnty(Type a,Type b) => x = x - 1; } return x; diff --git a/executable_semantics/testdata/next.6c b/executable_semantics/testdata/next.6c index c1324486b8f8..9b3d8bea3041 100644 --- a/executable_semantics/testdata/next.6c +++ b/executable_semantics/testdata/next.6c @@ -4,6 +4,6 @@ fn main () -> Int { - var Int: x = 0; + var Int x = 0; return x; } diff --git a/executable_semantics/testdata/pattern_init.6c b/executable_semantics/testdata/pattern_init.6c index 7fa0b9cd3526..b761b63073cb 100644 --- a/executable_semantics/testdata/pattern_init.6c +++ b/executable_semantics/testdata/pattern_init.6c @@ -3,6 +3,6 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception fn main() -> Int { - var (auto: x, auto: y) = (2, 3); + var (auto x, auto y) = (2, 3); return y - x - 1; } diff --git a/executable_semantics/testdata/pattern_variable_fail.6c b/executable_semantics/testdata/pattern_variable_fail.6c index 938380adc9d7..3b87af7707f7 100644 --- a/executable_semantics/testdata/pattern_variable_fail.6c +++ b/executable_semantics/testdata/pattern_variable_fail.6c @@ -4,6 +4,6 @@ fn main() -> Int { // error - Int : x; + Int x; return 1; } diff --git a/executable_semantics/testdata/record1.6c b/executable_semantics/testdata/record1.6c index 9894837a9faa..367505f9ae0e 100644 --- a/executable_semantics/testdata/record1.6c +++ b/executable_semantics/testdata/record1.6c @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception fn main() -> Int { - var (.x = Int, .y = Int): t2 = (.x = 2, .y = 5); + var (.x = Int, .y = Int) t2 = (.x = 2, .y = 5); t2.y = 3; return t2.y - t2.x - 1; // 3 - 2 - 1 } diff --git a/executable_semantics/testdata/struct1.6c b/executable_semantics/testdata/struct1.6c index 7950f53ef191..5ebc4bfcffee 100644 --- a/executable_semantics/testdata/struct1.6c +++ b/executable_semantics/testdata/struct1.6c @@ -3,11 +3,11 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception struct Point { - var Int: x; - var Int: y; + var Int x; + var Int y; } fn main() -> Int { - var auto: p = Point(.x = 1, .y = 2); + var auto p = Point(.x = 1, .y = 2); return p.y - p.x - 1; } diff --git a/executable_semantics/testdata/struct2.6c b/executable_semantics/testdata/struct2.6c index ee43764a5909..a49a4ebee7b2 100644 --- a/executable_semantics/testdata/struct2.6c +++ b/executable_semantics/testdata/struct2.6c @@ -3,13 +3,13 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception struct Point { - var Int: x; - var Int: y; + var Int x; + var Int y; } fn main() -> Int { - var auto: p1 = Point(.x = 1, .y = 2); - var auto: p2 = p1; + var auto p1 = Point(.x = 1, .y = 2); + var auto p2 = p1; p2.x = 3; return p1.x - 1; } diff --git a/executable_semantics/testdata/struct3.6c b/executable_semantics/testdata/struct3.6c index 3b425545df37..8e41e0ac9bf4 100644 --- a/executable_semantics/testdata/struct3.6c +++ b/executable_semantics/testdata/struct3.6c @@ -3,8 +3,8 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception struct Point { - var Int: x; - var Int: y; + var Int x; + var Int y; } fn main() -> Int { diff --git a/executable_semantics/testdata/tuple1.6c b/executable_semantics/testdata/tuple1.6c index c6b7a382f0b7..86d99b6c0ba3 100644 --- a/executable_semantics/testdata/tuple1.6c +++ b/executable_semantics/testdata/tuple1.6c @@ -3,8 +3,8 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception fn main() -> Int { - var Int: x = (1); - var (Int,Int): t2 = (5, 2); + var Int x = (1); + var (Int,Int) t2 = (5, 2); t2[0] = 3; return t2[0] - t2[1] - x; } diff --git a/executable_semantics/testdata/tuple2.6c b/executable_semantics/testdata/tuple2.6c index 42040de20aad..bc1980ae1730 100644 --- a/executable_semantics/testdata/tuple2.6c +++ b/executable_semantics/testdata/tuple2.6c @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception fn main() -> Int { - var (Int,): t1 = (5,); - var (Int, Int): t2 = (2, 3,); + var (Int,) t1 = (5,); + var (Int, Int) t2 = (2, 3,); return t1[0] - t2[0] - t2[1]; } diff --git a/executable_semantics/testdata/tuple3.6c b/executable_semantics/testdata/tuple3.6c index adae5da59ff5..3aa1222a8d30 100644 --- a/executable_semantics/testdata/tuple3.6c +++ b/executable_semantics/testdata/tuple3.6c @@ -3,6 +3,6 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception fn main() -> Int { - var (Int, .x = Int): t = (3, .x = 2); + var (Int, .x = Int) t = (3, .x = 2); return t.x + 1 - t[0]; } diff --git a/executable_semantics/testdata/tuple4.6c b/executable_semantics/testdata/tuple4.6c index 2d4bd3d38830..667e5ef6cb41 100644 --- a/executable_semantics/testdata/tuple4.6c +++ b/executable_semantics/testdata/tuple4.6c @@ -3,6 +3,6 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception fn main() -> Int { - var auto: t = (.x = 2, 3); + var auto t = (.x = 2, 3); return 0; } diff --git a/executable_semantics/testdata/tuple5.6c b/executable_semantics/testdata/tuple5.6c index c36e695db741..a5c2ecc25868 100644 --- a/executable_semantics/testdata/tuple5.6c +++ b/executable_semantics/testdata/tuple5.6c @@ -5,6 +5,6 @@ // Test the that field order matters for tuples. fn main() -> Int { - var (.x = Int, .y = Int): t = (.y = 2, .x = 3); + var (.x = Int, .y = Int) t = (.y = 2, .x = 3); return 0; } diff --git a/executable_semantics/testdata/tuple_assign.6c b/executable_semantics/testdata/tuple_assign.6c index 392babb1c4a1..bdb28848cac4 100644 --- a/executable_semantics/testdata/tuple_assign.6c +++ b/executable_semantics/testdata/tuple_assign.6c @@ -3,8 +3,8 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception fn main() -> Int { - var auto: x = 0; - var auto: y = 1; + var auto x = 0; + var auto y = 1; (x, y) = (5, -5); return x + y; } diff --git a/executable_semantics/testdata/tuple_equality.6c b/executable_semantics/testdata/tuple_equality.6c index c8e421ed5c0c..ff9256919e87 100644 --- a/executable_semantics/testdata/tuple_equality.6c +++ b/executable_semantics/testdata/tuple_equality.6c @@ -3,8 +3,8 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception fn main() -> Int { - var (Int,Int): t1 = (5, 2); - var (Int,Int): t2 = (5, 2); + var (Int,Int) t1 = (5, 2); + var (Int,Int) t2 = (5, 2); if (t1 == t2) { return 0; } else { diff --git a/executable_semantics/testdata/tuple_equality2.6c b/executable_semantics/testdata/tuple_equality2.6c index 88059622ef3e..c91b6ccf0f2e 100644 --- a/executable_semantics/testdata/tuple_equality2.6c +++ b/executable_semantics/testdata/tuple_equality2.6c @@ -3,8 +3,8 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception fn main() -> Int { - var (Int,Int): t1 = (5, 2); - var (Int,Int): t2 = (5, 4); + var (Int,Int) t1 = (5, 2); + var (Int,Int) t2 = (5, 4); if (t1 == t2) { return 1; } else { diff --git a/executable_semantics/testdata/tuple_equality3.6c b/executable_semantics/testdata/tuple_equality3.6c index 185f02e0307e..6b638357249d 100644 --- a/executable_semantics/testdata/tuple_equality3.6c +++ b/executable_semantics/testdata/tuple_equality3.6c @@ -3,8 +3,8 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception fn main() -> Int { - var (Int,Int): t1 = (5, 2); - var (Int,): t2 = (5,); + var (Int,Int) t1 = (5, 2); + var (Int,) t2 = (5,); if (t1 == t2) { return 1; } else { diff --git a/executable_semantics/testdata/tuple_match.6c b/executable_semantics/testdata/tuple_match.6c index bc98c3ee2e89..3b633d0def47 100644 --- a/executable_semantics/testdata/tuple_match.6c +++ b/executable_semantics/testdata/tuple_match.6c @@ -3,9 +3,9 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception fn main() -> Int { - var auto: t = (5, 2); + var auto t = (5, 2); match (t) { - case (auto: a, auto: b) => + case (auto a, auto b) => return a + b - 7; } } diff --git a/executable_semantics/testdata/tuple_match2.6c b/executable_semantics/testdata/tuple_match2.6c index 3af74a674632..579102390fdb 100644 --- a/executable_semantics/testdata/tuple_match2.6c +++ b/executable_semantics/testdata/tuple_match2.6c @@ -5,9 +5,9 @@ // Test matching with a mixture of positional and named fields. fn main() -> Int { - var auto: t = (2, .x = 5); + var auto t = (2, .x = 5); match (t) { - case (auto: a, .x = auto: b) => + case (auto a, .x = auto b) => return a - b + 3; } } diff --git a/executable_semantics/testdata/tuple_match3.6c b/executable_semantics/testdata/tuple_match3.6c index 067a1baebee7..507d219dab44 100644 --- a/executable_semantics/testdata/tuple_match3.6c +++ b/executable_semantics/testdata/tuple_match3.6c @@ -5,9 +5,9 @@ // Test matching of a tuple inside a tuple. fn main() -> Int { - var auto: t = ((1,2),(3,4)); + var auto t = ((1,2),(3,4)); match (t) { - case ((auto: a, auto: b), auto: c) => + case ((auto a, auto b), auto c) => return a - b + c[0] - c[1] + 2; } } diff --git a/executable_semantics/testdata/type_compute.6c b/executable_semantics/testdata/type_compute.6c index fa4f9bf68cfa..a407e58cde92 100644 --- a/executable_semantics/testdata/type_compute.6c +++ b/executable_semantics/testdata/type_compute.6c @@ -2,11 +2,11 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -fn Id(Type: t) => t; +fn Id(Type t) => t; // Test non-trivial type expression in variable declaration statement. fn main() -> Int { - var Id(Int): x = 0; + var Id(Int) x = 0; return x; } diff --git a/executable_semantics/testdata/type_compute2.6c b/executable_semantics/testdata/type_compute2.6c index ff50e2cadcbc..00f8d3db8933 100644 --- a/executable_semantics/testdata/type_compute2.6c +++ b/executable_semantics/testdata/type_compute2.6c @@ -2,7 +2,7 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -fn Id(Type: t) => t; +fn Id(Type t) => t; // Test non-trivial type expression in return type. diff --git a/executable_semantics/testdata/type_compute3.6c b/executable_semantics/testdata/type_compute3.6c index 9135f477c5d8..1c62bbbcaff9 100644 --- a/executable_semantics/testdata/type_compute3.6c +++ b/executable_semantics/testdata/type_compute3.6c @@ -2,11 +2,11 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -fn Id(Type: t) => t; +fn Id(Type t) => t; // Test non-trivial type expression in parameter type. -fn f(Id(Int): x) -> Int { +fn f(Id(Int) x) -> Int { return x; } diff --git a/executable_semantics/testdata/while1.6c b/executable_semantics/testdata/while1.6c index ed80d1db47c4..71dbc8d103ab 100644 --- a/executable_semantics/testdata/while1.6c +++ b/executable_semantics/testdata/while1.6c @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception fn main() -> Int { - var auto: x = 2; + var auto x = 2; while (not (x == 0)) x = x - 1; return x;