Redparse 0.8.1 Released

RedParse version 0.8.1 has been released!

RedParse is a ruby parser written in pure ruby. Instead of YACC or
ANTLR, it’s parse tool is a home-brewed “compiler-interpreter”. (The
tool is LALR(1)-equivalent and the ‘parse language’ is pretty nice,
even in it’s current crude form.)

My intent is to have a completely correct parser for ruby, in 100%
ruby. It’s not all there yet, but I’m getting pretty close. Currently,
RedParse can parse slightly in excess of 99% of ruby files found in
the wild. For known problems, see below.


0.8.1 / 2009-04-21

  • 4 minor enhancements:
    • fixed embarassing permissions problems
    • version.rb and History.txt were missing from the release
    • I left off the dependancy on reg, oops!
    • hacked up tests to ignore trivial compare errors

== Benefits:

  • Pure ruby, through and through. No part is written in C, YACC,
    ANTLR, lisp, assembly, intercal, befunge or any other language
    except ruby.
  • Pretty AST trees (at least, I think so). (To program for, not
    necessarily to look at.)
  • AST trees closely mirror the actual structure of source code.
  • ParseTree format output too, if you want that.
  • Did I mention that there’s no YACC at all? YACC grammars are
    notoriously difficult to modify, (I’ve never successfully done it)
    but I’ve found it easy, at times even pleasant to modify the parse
    rules of this grammar as necessary.
  • Relatively small parser: 70 rules in 240 lines
    (vs (by my count) 320 rules in 2200 lines for MRI 1.8.7. This is
    by no means a fair comparison, tho, since RubyLexer does a lot
    more than MRI’s lexer, and MRI’s 2200 lines include its
    actions (which occupy somewhere under 3100 lines in RedParse).
    Also, what is a rule? I counted most things which required a
    separate action in MRI’s parser, I’m not sure if that’s fair.
    But in the end, I still think RedParse is still much easier to
    understand than MRI’s parse.y.)
  • “loosey-goosey” parser happily parses many expressions which normal
    ruby considers errors.

== Drawbacks:

  • Pathetically, rediculously slow (still working on that).

  • Error handling is very minimal right now.

  • No warnings at all.

  • Some expressions aren’t parsed correctly. see below.

  • Line numbers in ParseTrees not supported yet.

  • AST tree format is not finalized yet.

  • Unit test takes a fairly long time.

  • Lots of warnings printed during unit test.

  • Debugging parse rules is not straightforward.

  • No support for ruby 1.9.

  • No support for any charset but ascii (until rubylexer gets it).

  • “loosey-goosey” parser happily parses many expressions which normal
    ruby considers errors.

  • The following expressions are known to parse incorrectly currently:

  • 1, V

  • “#{}”""

  • begin;mode;rescue;o_chmod rescue nil;end

  • def i;"…#{@@c = 1}";end

  • e { |c|; print “%02X” % c }

  • {|f| ; }

  • %W(white\ \ \ \ \ space).should == ["white ", " ", " “, " space”]

  • %w[- \ e]

  • %w[- \ ]

  • module A; b; rescue C=>d; e; else g; ensure f; end

  • class A; b; rescue C=>d; e; else g; ensure f; end

  • class<<A; b; rescue C=>d; e; else g; ensure f; end

  • %w![ ] { } ( ) | - * . \ ? + ^ $ #!



This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs