Skip to content

Commit

Permalink
Allow optional newline between "do {}" and "while" (#220)
Browse files Browse the repository at this point in the history
Fixes #219
  • Loading branch information
benhoyt authored Jan 1, 2024
1 parent 9241da4 commit 0fd695b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions interp/interp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ NR==3, NR==5 { print NR }
{`BEGIN { s="x"; while (s=="x") { print s; s="y" } }`, "", "x\n", "", ""},
{`BEGIN { s="x"; while (s!="") { print s; s="" } }`, "", "x\n", "", ""},
{`BEGIN { s="x"; while (s) { print s; s="" } }`, "", "x\n", "", ""},
{"BEGIN { do { print 1 }\nwhile (0) }", "", "1\n", "", ""},
// regression tests for break and continue with nested loops
{`
BEGIN {
Expand Down
1 change: 1 addition & 0 deletions parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ func (p *parser) stmt() ast.Stmt {
p.next()
p.optionalNewlines()
body := p.loopStmts()
p.optionalNewlines()
p.expect(WHILE)
p.expect(LPAREN)
cond := p.expr()
Expand Down

0 comments on commit 0fd695b

Please sign in to comment.