I added an optional semi-colon before "else".
Syntax: if ... then ...; else ...
This commit is contained in:
parent
c76ec00c9b
commit
19f6981ae7
4
AST.ml
4
AST.ml
@ -397,6 +397,7 @@ and conditional = {
|
||||
test : expr;
|
||||
kwd_then : kwd_then;
|
||||
ifso : instruction;
|
||||
terminator : semi option;
|
||||
kwd_else : kwd_else;
|
||||
ifnot : instruction
|
||||
}
|
||||
@ -1037,12 +1038,13 @@ and print_fail {kwd_fail; fail_expr} =
|
||||
print_expr fail_expr
|
||||
|
||||
and print_conditional node =
|
||||
let {kwd_if; test; kwd_then; ifso;
|
||||
let {kwd_if; test; kwd_then; ifso; terminator;
|
||||
kwd_else; ifnot} = node in
|
||||
print_token kwd_if "if";
|
||||
print_expr test;
|
||||
print_token kwd_then "then";
|
||||
print_instruction ifso;
|
||||
print_terminator terminator;
|
||||
print_token kwd_else "else";
|
||||
print_instruction ifnot
|
||||
|
||||
|
1
AST.mli
1
AST.mli
@ -381,6 +381,7 @@ and conditional = {
|
||||
test : expr;
|
||||
kwd_then : kwd_then;
|
||||
ifso : instruction;
|
||||
terminator : semi option;
|
||||
kwd_else : kwd_else;
|
||||
ifnot : instruction
|
||||
}
|
||||
|
@ -581,15 +581,16 @@ proc_call:
|
||||
fun_call { $1 }
|
||||
|
||||
conditional:
|
||||
If expr Then instruction Else instruction {
|
||||
let region = cover $1 (instr_to_region $6) in
|
||||
If expr Then instruction option(SEMI) Else instruction {
|
||||
let region = cover $1 (instr_to_region $7) in
|
||||
let value = {
|
||||
kwd_if = $1;
|
||||
test = $2;
|
||||
kwd_then = $3;
|
||||
ifso = $4;
|
||||
kwd_else = $5;
|
||||
ifnot = $6}
|
||||
terminator = $5;
|
||||
kwd_else = $6;
|
||||
ifnot = $7}
|
||||
in {region; value}
|
||||
}
|
||||
|
||||
|
@ -6,9 +6,6 @@ type store is
|
||||
funded : bool;
|
||||
end
|
||||
|
||||
const foo : map (string, nat) = map "X" -> 10; "Y" -> 11 end
|
||||
const bar : set (int) = set 1; 1+1; f(3); end
|
||||
|
||||
entrypoint contribute (storage store : store;
|
||||
const sender : address;
|
||||
const amount : mutez)
|
||||
@ -16,7 +13,7 @@ entrypoint contribute (storage store : store;
|
||||
var operations : list (operation) := []
|
||||
begin
|
||||
if now > store.deadline then
|
||||
fail "Deadline passed"
|
||||
fail "Deadline passed";
|
||||
else
|
||||
case store.backers[sender] of
|
||||
None -> store.backers[sender] := Some (amount)
|
||||
@ -59,7 +56,7 @@ entrypoint claim (storage store : store; const sender : address)
|
||||
else
|
||||
begin
|
||||
operations := [Transfer (sender, amount)];
|
||||
remove sender from map store.backers
|
||||
remove sender from map store.backers;
|
||||
end
|
||||
end
|
||||
end with (store, operations)
|
||||
|
Loading…
Reference in New Issue
Block a user