Skip to content

Commit 0fd695b

Browse files
authored
Allow optional newline between "do {}" and "while" (#220)
Fixes #219
1 parent 9241da4 commit 0fd695b

2 files changed

Lines changed: 2 additions & 0 deletions

File tree

interp/interp_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ NR==3, NR==5 { print NR }
155155
{`BEGIN { s="x"; while (s=="x") { print s; s="y" } }`, "", "x\n", "", ""},
156156
{`BEGIN { s="x"; while (s!="") { print s; s="" } }`, "", "x\n", "", ""},
157157
{`BEGIN { s="x"; while (s) { print s; s="" } }`, "", "x\n", "", ""},
158+
{"BEGIN { do { print 1 }\nwhile (0) }", "", "1\n", "", ""},
158159
// regression tests for break and continue with nested loops
159160
{`
160161
BEGIN {

parser/parser.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ func (p *parser) stmt() ast.Stmt {
379379
p.next()
380380
p.optionalNewlines()
381381
body := p.loopStmts()
382+
p.optionalNewlines()
382383
p.expect(WHILE)
383384
p.expect(LPAREN)
384385
cond := p.expr()

0 commit comments

Comments
 (0)