Robert Klemme <shortcutter / googlemail.com> writes:

> I *think* this is at least partly due to Ruby's convenient and very
> flexible syntax.  IOW, the parser has no means to detect the error
> line as it could be in several places - likely too many to report.
> Also, this is how parsers work.  From my limited insight into the
> parser generation business it would require a) a different parser
> generator that is much smarter or b) a lot of effort that it's not
> worth IMHO.

I'll note that perl has a similarly flexible syntax, yet I don't hear
people new to perl complaining about this.  Perhaps this is because
perl has more to complain about, from a newbie perspective, but I
think it's also because perl gives better syntax error messages.  For
example, if you get a runaway unclosed string or regexp (//) operator,
the perl interpreter will, in the syntax error, also say something
like "possible runaway string beginning line NN".

This seems to me like it would be a simple addition to the ruby
parser, to mention the line number of the thing it's trying to close
when expecting tEND, or ']', or some other nested thing that can go
off the end of the file.