Re: Syntax checker wtf?



Daniel Martin wrote:
Robert Klemme <shortcutter@xxxxxxxxxxxxxx> 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,

I don't think so. For example, you must terminate statements with a ";" (or did that change in the latest version?) and you cannot omit parentheses. That makes up for a significant difference in flexibility of the two languages.

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".

I know that perl does this and I liked that at the time when I used perl. But:

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.

IMHO you're greatly underestimating the effor. I guess even for perl it was not "a simple addition" - and from what I can see a lot more efforts were put into perl vs. ruby.

Kind regards

robert
.



Relevant Pages

  • Re: Syntax checker wtf?
    ... the parser has no means to detect the error ... I'll note that perl has a similarly flexible syntax, ... example, if you get a runaway unclosed string or regexp operator, ...
    (comp.lang.ruby)
  • Re: a good TeX parser for use by software that needs to read TeX?
    ... : read TeX? ... In particular, has anyone used the perl Text::TeX parser, ... In addition, push $found into a list @commands, ...
    (comp.text.tex)
  • Re: Precedence of exponentiation
    ... The parser I'm writing isn't even written in Perl ... (nor does it use yacc), and that's my primary reason for this topic. ... > Digits: Digit | Digit Digits ...
    (comp.lang.perl.misc)
  • Re: Writing a C++ Style Checker
    ... This is going to be seriously hard work. ... you may be able to persuade your compiler to do the ... with a relatively simple parser, leaving the hard work of 'is this ... Perl distribution, which was intended to allow access to C structures by ...
    (comp.lang.perl.misc)
  • Re: How to read and parse a remote XML file with Java
    ... What type of XML parser are you using in Python, PHP and Perl? ... It would be silly to compare a Perl SAX parser with a Java DOM parser or vice versa. ... The EOL transition period is from Dec, 11 2006, until the General Availability of the next Java version, Java SE 7, currently planned for the summer of 2008. ...
    (comp.lang.java.programmer)