You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
awk: a comment line next to a newline breaks the statement ("invalid statement start") #164
A # comment on a line of its own is rejected as a syntax error when it sits
between two statements that are separated by ; or by another comment line,
after if (...), after switch (...) {, or inside a function call argument
list. Real-world awk scripts are full of comment lines, so this is the most
frequent parse failure in the GNU test suite: 31 tests stop on it.
Reproduction
Rust (incorrect)
$ printf'BEGIN {\n x = 1;\n # set y\n y = 2\n print x, y\n}\n'> c.awk
$ ./target/release/awk -f c.awk
Error: Syntax error
╭─[ c.awk:3:12 ]
3 │ # set y
│ ╰── Unexpected token: invalid statement start.
GNU (correct)
$ gawk -f c.awk
1 2
Other shapes that fail the same way:
BEGIN {
# first comment line# second comment lineprint1 }
BEGIN { if (1)
# commentprint2 }
BEGIN { printf("%s\n",
# comment"x") }
Activity