[grammarians] Comparison to RubyFront grammar
MenTaLguY
mental at rydia.net
Tue Oct 24 18:32:12 EDT 2006
On Tue, 2006-10-24 at 16:26 -0500, Nick Sieger wrote:
> I for one am still interested. I was looking at the rubyfront grammar
> this weekend and I don't think it should be too hard to port to ANTLR
> 3.
>
> Also, what about the idea of a multi-pass parser? With Ruby's syntax
> so complex, it might help to break down into several stages for
> understandability.
That was Terence's opinion as well, if I remember correctly (Hi Ter!).
I've not had time to look at the RubyFront grammar deeply, but I was a
little surprised that Yong Zhi was apparently able to do heredocs
without multiple passes, actually.
> Also, on the JRuby project, we have a need for a more fault-tolerant
> parser because eventually IDEs will be using it to parse partial
> source files for refactoring and analysis. Any ideas here?
Well ... not much. One bit of advice from my minor experience in
hand-rolling "fuzzy" parsers for reverse-engineered languages: it's
really easy for "fuzzy" parsers to turn into effectively meaningless
piles of heuristics.
You need a strict grammar as a starting point anyway. At that point,
you can make a "fuzzy" version largely by establishing specific
"fallback points" where things can end up in an "unparsable blob"
terminal, and otherwise keep it as strict as possible. Some heuristics
(perhaps as a second pass) are okay, but you have to be able to account
for their interactions so that you don't mis-match a valid input.
In the case of an IDE, those same fallback points might be good units of
granularity at which to only re-parse subranges of a changed file --
that way, you can localize the effects of things like edits which result
in mismatched braces.
Terence might have some more useful ideas and/or practical experience
about that sort of thing as well. HE'S the grammar expert after all. :)
> MenTaL: I don't think you made it to RubyConf did you? Sorry you
> missed it.
No ... I probably won't go until/unless I would be giving a
presentation, honestly. Unless I was sure to contribute significantly,
I wouldn't feel right taking up a scarce slot.
-mental
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: This is a digitally signed message part
Url : http://rubyforge.org/pipermail/rubygrammar-grammarians/attachments/20061024/7caf70b4/attachment-0001.bin
More information about the Rubygrammar-grammarians
mailing list