Fix EOS handling in parser