Visualization of Ruby's Grammar
Posted Oct 31, 2006 16:47 UTC (Tue) by
mikov (subscriber, #33179)
In reply to:
Visualization of Ruby's Grammar by tjc
Parent article:
Visualization of Ruby's Grammar
Are you saying that Ruby can not be parsed with an
ANTLR grammar, or that it's just the automatic conversion from LALR(1)
that is problematic? Even if the generated grammar is incorrect, I suspect
that a corrected version would look substantially the same, assuming that
it can be generated at all.
I have a problem with the automatic conversion. I am sure pretty much
anything (well, within limits) can eventually be parsed with ANTLR using
backtracking, with varying amount of effort. In this case, since the
generated grammar is almost certainly not correct, and since the person
who did it even neglected to mention that, it cannot be taken seriously.
I have no idea whether the diagram looks similar to one for the correct
grammar. Do you ? Oh, it will probably have similar node names, but that
doesn't really tell us much, which is my next point.
I have no idea what the diagram really means. Where
is it defined ? Who uses it ? Subjective observations that one "looks
cleaner" than the other are meaningless. I could rearrange any diagram to
look terrible. Perhaps one could derive some value from it, of one already
had intimate knowledge about the grammar, but not the other way around.
On the contrary, I find this very interesting! See
Bruce Person's comment about the primary node in Ruby, for example.
I agree that his comment is interesting. Then I am pretty sure it is
because he probably knows Ruby, not because he actually used the diagram
to derive insight. His comments about the size of the parser make sense in
the same context. The observation about the lexical analyzer doing a lot
of work especially doesn't stand on its own - it is impossible to deduce
that
from the diagram.
The problem is that the entire thing it is based on a wrong premise.
Even if it can generate interesting comments and useful tidbits of
information, ultimately it is misleading. A casual reader could be lead to
believe that:
- Conversion between LR and LL is trivial.
- This diagram is the true diagram of Ruby's syntax. (whatever that
means)
- Diagrams are often used as tools to study and evaluate grammars
- Subjective evaluation of the artistic properties of the diagram
corresponds to properties of the language.
All these things are false.
(
Log in to post comments)