From 9eac5681b2e30323663ff22406b065d0f875bb21 Mon Sep 17 00:00:00 2001
From: James Clark
@@ -6048,7 +6048,7 @@ Function and worker execution
block-function-body :=
{
[default-worker-init named-worker-decl+] default-worker }
-default-worker-init := sequence-stmt
-default-worker := sequence-stmt
+default-worker-init := statement*
+default-worker := statement*
named-worker-decl :=
- [annots] worker
worker-name return-type-descriptor {
sequence-stmt }
+ [annots] worker
worker-name return-type-descriptor statement-block
worker-name := identifier
Function and worker execution
@@ -6057,10 +6057,10 @@ Function and worker execution
whereas variables declared in default-worker are not.
-The execution of a worker's sequence-stmt may result in the execution of a
+The execution of a worker's statements may result in the execution of a
statement that causes the worker to terminate. For example, a return statement
causes the worker to terminate. If this does not happen, then the worker
-terminates as soon as it has finished executing its sequence-stmt. In this case,
+terminates as soon as it has finished executing its statements. In this case,
the worker terminates normally, and the termination value is nil. In other
words, falling off the end of a worker is equivalent to return;
,
which is in turn equivalent to return ();
.
@@ -6098,7 +6098,6 @@
statement := action-stmt - | block-stmt | local-var-decl-stmt | xmlns-decl-stmt | assignment-stmt @@ -6106,15 +6105,21 @@Statement execution
| destructuring-assignment-stmt | call-stmt | if-else-stmt - | match-stmt - | foreach-stmt - | while-stmt - | break-stmt + | regular-compound-stmt | continue-stmt - | fork-stmt + | break-stmt + | stmt-with-on-fail + | fail-stmt | panic-stmt | return-stmt - | lock-stmt + | fork-stmt + +regular-compound-stmt := + do-stmt + | match-stmt + | foreach-stmt + | while-stmt + | lock-stmt
The execution of any statement may involve the evaluation of actions and @@ -6133,14 +6138,17 @@
sequence-stmt := statement* -block-stmt :={
sequence-stmt}
+class="grammar"> +statement-block :={
statement*}
-A sequence-stmt
executes its statements sequentially. A
-block-stmt
is executed by executing its sequence-stmt
.
+A statement-block
is a syntactic grouping of statements, which are
+executed sequentially.
query-action := query-pipeline do-clause -do-clause :=do
block-stmt +do-clause :=do
statement-block
The clauses in the query-pipeline of query-action are executed in the same way @@ -6645,7 +6653,7 @@
The query-action is executed as follows. For each input frame f -emitted by the query-pipeline, execute the block-stmt with f in +emitted by the query-pipeline, execute the statement-block with f in scope. If a clause in the query-pipeline completes early with error e, the result of the query-action is e. Otherwise, the result of the query-action is nil. @@ -6669,7 +6677,7 @@
The scope of variables declared in a local-var-decl-stmt
starts
-immediately after the statement and continues to the end of the block statement
+immediately after the statement and continues to the end of the statement block
in which it occurs.
@@ -7177,31 +7185,37 @@
if-else-stmt := -if
expression block-stmt - [else
if
expression block-stmt ]* - [else
block-stmt ] +if
expression statement-block + [else
if
expression statement-block ]* + [else
statement-block ]
The if-else statement is used for conditional execution.
The static type of the expression following if
must be boolean.
-When an expression is true then the corresponding block statement is executed
+When an expression is true then the corresponding statement block is executed
and the if statement completes. If no expression is true then, if the else block
-is present, the corresponding block statement is executed.
+is present, the corresponding statement block is executed.
do-stmt := do
statement-block
+
+match-stmt :=match
action-or-expr{
match-clause+}
match-clause := - match-pattern-list [match-guard]=>
block-stmt + match-pattern-list [match-guard]=>
statement-block match-guard :=if
expression
-A match statement selects a block statement to execute based on which patterns a +A match statement selects a statement block to execute based on which patterns a value matches.
@@ -7220,14 +7234,14 @@
The scope of any variables created in a match-pattern-list of a match-clause is -both the match-guard, if any, and the block-stmt in that match-clause. The +both the match-guard, if any, and the statement-block in that match-clause. The static type of the expression in match-guard must be a subtype of boolean.
@@ -7337,16 +7351,16 @@foreach-stmt := -foreach
typed-binding-patternin
action-or-expr block-stmt +foreach
typed-binding-patternin
action-or-expr statement-block
-A foreach statement iterates over an iterable value, executing a block statement +A foreach statement iterates over an iterable value, executing a statement block once for each value in the iterable value's iteration sequence. The static type of action-or-expr must be an iterable type with an iteration completion type of nil.
-The scope of any variables created in typed-binding-pattern is block-stmt. These +The scope of any variables created in typed-binding-pattern is statement-block. These variables are implicitly final.
@@ -7366,7 +7380,7 @@
while-stmt :=while
expression block-stmt +class="grammar">while-stmt :=while
expression statement-block
-A while statement repeatedly executes a block statement so long as a +A while statement repeatedly executes a statement block so long as a boolean-valued expression evaluates to true.
@@ -7404,7 +7418,7 @@
panic-stmt :=-panic
expression;
-
-A panic statement terminates the current worker abnormally. The result of
-evaluating expression
provides the termination value of the worker.
-
-The static type of expression
must be a subtype of error.
-
return-stmt :=-return
[ action-or-expr ];
-
-A return statement terminates the current worker normally.The result of -evaluating the action-or-expr provides the termination value of the worker. If -action-or-expr is omitted, then the termination value is nil. -
-lock-stmt :=lock
block-stmt +class="grammar">lock-stmt :=lock
statement-block
-A lock-stmt executing in the context of some strand must execute its block-stmt +A lock-stmt executing in the context of some strand must execute its statement-block in such a way that the effect on the state of the program is consistent with the -execution of the block-stmt not being interleaved with the execution of a +execution of the statement-block not being interleaved with the execution of a lock-stmt on any other strand.
@@ -7501,6 +7489,49 @@
stmt-with-on-fail := regular-compound-stmt on-fail-clause +on-fail-clause :=+on
fail
typed-binding-pattern statement-block +
fail-stmt :=+fail
expression;
+
panic-stmt :=+panic
expression;
+
+A panic statement terminates the current worker abnormally. The result of
+evaluating expression
provides the termination value of the worker.
+
+The static type of expression
must be a subtype of error.
+
return-stmt :=+return
[ action-or-expr ];
+
+A return statement terminates the current worker normally.The result of +evaluating the action-or-expr provides the termination value of the worker. If +action-or-expr is omitted, then the termination value is nil. +
+