The bbdd8bed residue, ruled by the Go derivation (ww's for IS the Go
for; the cstage grammar is the language definition and already the
Go-shaped one):
- bare `for { }` accepted (align UP to parse.c:1023, incl. for-else);
- 3-clause cond and post each omissible — `for (init;; post)`,
`for (init; cond)`, `for (init;)` (align UP, parse.c:1092-1097);
- 2-clause `for (cond; post)` REJECTED (align DOWN): the form exists
in neither Go nor cstage (parse.c:1101 eats a stray ';' then
requires ')'), so the old wwstage accept was a parser bug. The
reject wording mirrors cstage's failure mode per stage.
forhdr_{brace,emptymid,partial} run fixtures pin the accepted forms
byte-identically; forhdr_twoclause_reject pins both reject fragments.
Corpus pin 1745/346/21/209/1169/3490.
21 lines
286 B
Plaintext
21 lines
286 B
Plaintext
//ww:run-exit 12
|
|
package main;
|
|
export fn main() i32 = {
|
|
let a: i32 = 0;
|
|
for (let i: i32 = 0; i < 5) {
|
|
i += 1;
|
|
a = i;
|
|
};
|
|
let b: i32 = 0;
|
|
for (let j: i32 = 0;) {
|
|
j += 1;
|
|
if (j >= 3) { break; };
|
|
};
|
|
b = 3;
|
|
let k: i32 = 0;
|
|
for (k < 4;) {
|
|
k += 1;
|
|
};
|
|
return a + b + k;
|
|
};
|