Racc is a LALR(1) parser generator.
It is written in Ruby itself, and generates Ruby program.
I think I may have asked this before but...
is racc the same thing as that used by ruby_parser [1] to parse ruby?
If so then why does [1] say that it is a C extension? I am so confused.
Also isn't racc built into the ruby distro? Is this an updated version
of that? Will it be rolled into trunk?
Thanks!
-=r
I think I may have asked this before but...
is racc the same thing as that used by ruby_parser [1] to parse ruby?
yes
If so then why does [1] say that it is a C extension? I am so confused.
there might be a few things your confused by. [1] is the link to the parse tree project page. PT is a C extension. RP uses racc which has a C extension to optimize its performance. A majority of racc is implemented in ruby.
Also isn't racc built into the ruby distro? Is this an updated version
of that? Will it be rolled into trunk?
it is, the C extension ships with the ruby distro. This is an updated release, but most if not all of the updates pertain to the racc compiler, which does NOT ship with the ruby distro. It won't be rolled in.
there might be a few things your confused by. [1] is the link to the
parse tree project page. PT is a C extension. RP uses racc which has a
C extension to optimize its performance. A majority of racc is
implemented in ruby.
So racc has an optional C extension to optimize its performance, and
that one part is built into the base ruby distro [oddly]. I guess I
could look into it more to know what the difference between the parser
and compiler is. Cool.
Thanks.
-=r
I'm glad you asked! Of course it can! For parsing JavaScript, I
present to you two solutions. One is pure ruby and kind of slow, and
the other one is C and super fast!
RKelly is a pure ruby javascript parser that uses racc:
I haven't released a gem yet, but I could be persuaded to since I'm not
really doing much with it lately. RKelly will give you an AST of your
javascript.
Your second option is Johnson. It uses Spidermonkey, is really fast,
and can return a JavaScript AST:
I'm glad you asked! Of course it can! For parsing JavaScript, I
present to you two solutions. One is pure ruby and kind of slow, and
the other one is C and super fast!
Yay!
Google assert_javascript. It's a great library - we use it all the time at work, but it's hard to get started with, because of the bugs in its root library. It can't parse 'Ajax.Request', but it can parse 'var ajax = Ajax.Request', so it's incompatible with generated code.
It's a re-imagining of assert_rjs, but without the noise from regular expressions.
I will shortly be rewriting assert_javascript using one of these parsers instead...
On Wed, Dec 31, 2008 at 03:24:36AM +0900, Phlip wrote:
racc 1.4.6 has been released!
YAY!!
Can it lex JavaScript?
I'm glad you asked! Of course it can! For parsing JavaScript, I
present to you two solutions. One is pure ruby and kind of slow, and
the other one is C and super fast!