petdance/scratch — Issue #234: Parrot will not parse PIR missing newline at EOF
Author: petdance
Created: 2011-11-01 05:41:42+00:00
State: open
Labels: bug, imcc, Pri-normal, Sev-medium

This script:
{{{
perl -e 'print ".sub foo\n\tsay \"Hello, world\"\n.end\n# Last line"' > x.pir
}}}

produces a .pir file with no newline at the end. (Vim really WANTS to add a trailing newline, so beware how you look at it.)

You can check with
{{{
od -tx1z x.pir
}}}
which outputs something like:
{{{
0000000 2e 73 75 62 20 66 6f 6f 0a 09 73 61 79 20 22 48 >.sub foo..say "H<
0000020 65 6c 6c 6f 2c 20 77 6f 72 6c 64 22 0a 2e 65 6e >ello, world"..en<
0000040 64 0a 23 20 4c 61 73 74 20 6c 69 6e 65 >d.# Last line<
0000055
}}}

At any rate, feeding that input to parrot (v2.0) produces:
{{{
austin@andLinux:~/kakapo$ parrot --output x.pbc x.pir
error:imcc:syntax error, unexpected $undefined, expecting $end (' ')
in file 'x.pir' line 4
}}}

Appending a newline satisfies the parser.

Originally http://trac.parrot.org/parrot/ticket/1424