Recently in ruby_parser Category

ruby_parser (RP) is a ruby parser written in pure ruby (utilizing racc--which does by default use a C extension). RP's output is the same as ParseTree's output: s-expressions using ruby's arrays and base types.

As an example:

def conditional1(arg1) if arg1 == 0 then return 1 end return 0 end

becomes:

s(:defn, :conditional1, s(:args, :arg1), s(:scope, s(:block, s(:if, s(:call, s(:lvar, :arg1), :==, s(:arglist, s(:lit, 0))), s(:return, s(:lit, 1)), nil), s(:return, s(:lit, 0)))))

Changes:

2.0.5 / 2010-09-01

Why I Hate Yacc

| | Comments (0)
call_args2: arg_value tCOMMA args                                      opt_block_arg
          | arg_value tCOMMA                                               block_arg
          | arg_value tCOMMA                           tSTAR arg_value opt_block_arg
          | arg_value tCOMMA args tCOMMA               tSTAR arg_value opt_block_arg
          |                              assocs                        opt_block_arg
          |                              assocs tCOMMA tSTAR arg_value opt_block_arg
          | arg_value tCOMMA             assocs                        opt_block_arg
          | arg_value tCOMMA args tCOMMA assocs                        opt_block_arg
          | arg_value tCOMMA             assocs tCOMMA tSTAR arg_value opt_block_arg
          | arg_value tCOMMA args tCOMMA assocs tCOMMA tSTAR arg_value opt_block_arg
          |                                            tSTAR arg_value opt_block_arg
          |                                                                block_arg

ruby_parser (RP) is a ruby parser written in pure ruby (utilizing racc--which does by default use a C extension). RP's output is the same as ParseTree's output: s-expressions using ruby's arrays and base types.

As an example:

def conditional1(arg1) if arg1 == 0 then return 1 end return 0 end

becomes:

s(:defn, :conditional1, s(:args, :arg1), s(:scope, s(:block, s(:if, s(:call, s(:lvar, :arg1), :==, s(:arglist, s(:lit, 0))), s(:return, s(:lit, 1)), nil), s(:return, s(:lit, 0)))))

Changes:

2.0.4 / 2009-08-18

  • 1 minor enhancement:

    • Changed requires around to be more accurate.
  • 4 bug fixes:

    • Fixed .autotest for minitest
    • Fixed emacs escape lexing bug: "\C-\" (maglev/gemstone)
    • Fixed octal lexing edgecases. (maglev/gemstone)
    • Fixed regexp lexing edgecases. (maglev/gemstone)
  • http://parsetree.rubyforge.org/

ruby_parser (RP) is a ruby parser written in pure ruby (utilizing racc--which does by default use a C extension). RP's output is the same as ParseTree's output: s-expressions using ruby's arrays and base types.

As an example:

def conditional1(arg1) if arg1 == 0 then return 1 end return 0 end

becomes:

s(:defn, :conditional1, s(:args, :arg1), s(:scope, s(:block, s(:if, s(:call, s(:lvar, :arg1), :==, s(:arglist, s(:lit, 0))), s(:return, s(:lit, 1)), nil), s(:return, s(:lit, 0)))))

Changes:

2.0.3 / 2009-06-23

  • 4 minor enhancements:

    • Removed dead code handling d/regex match node cruft.
    • Switched to minitest
    • Updated .autotest and rakefile wrt rcov for new hoe capabilities
    • Updated hoe for new capabilities
  • 4 bug fixes:

    • Environment#all now deals with strange edge cases in RAD.
    • Fixed packaging/compilation issue.
    • Minor 1.9 fixes
    • hoe -> flay -> rubyparser rakefile circularity fixed
  • http://parsetree.rubyforge.org/

ParseTree EOL

| | Comments (3)

There seems to be some confusion and/or panic about ParseTree that I'd like to clear up:

ParseTree is dead on ruby 1.9 and there is no plan to make it work.

Because of changes to internals in 1.9, ParseTree simply can not work. I asked for hooks/options to allow us to get to the information but they never arrived.

Specifically if you're using ParseTree to access the AST of a live method/block/proc, you're SOL. If you're just using ParseTree to do static analysis, then you can switch to ruby_parser in about a minute of work and you're good to go.

Here is the plan for my projects:

  • RubyToC-1.0.0.5 = switching to ruby_parser
  • flog-2.1.0 = switching to ruby_parser
  • heckle-1.4.2 = dead, unless we can think of something soon.
  • ruby2ruby-1.2.2 = dropping block/proc support.
  • ruby_parser-2.0.2 = no clue why it has a dependency still, no worries here.
  • ZenHacks-1.0.1 = dropping block/proc support -- not that I support this.

I don't know the status of most of the projects dependent on PT or how they're going to deal with this issue. If you use one of these projects directly or indirectly and that project relies on PT for live method/block/proc, then you're probably going to be stuck on 1.8 for a while:

  • SuperCaller-1.0.0 = unsupported - can drop live method support
  • ambition-0.5.4
  • argible-0.1.1
  • integrity-0.1.9.3
  • merb-action-args-1.0.11
  • nitpick-1.0.2
  • protocol-0.8.1
  • red-4.1.7
  • reek-1.0.0 = probably doesn't need live analysis
  • roodi-1.3.5
  • ruby_diff-0.2
  • rubyjs-0.8.0
  • sake-1.0.15
  • thorero-action-args-0.9.4

There are probably other projects out there dependent on PT that I don't know about. All I've listed here are rubyforge gems that depend on PT in their gemspec.

You can check your gems using this:

gem list | egrep "(ambition|argible|integrity|merb-action-args|nitpick|protocol|red|reek|roodi|ruby_diff|rubyjs|sake|thorero-action-args)"

ruby_parser (RP) is a ruby parser written in pure ruby (utilizing racc--which does by default use a C extension). RP's output is the same as ParseTree's output: s-expressions using ruby's arrays and base types.

As an example:

def conditional1(arg1) if arg1 == 0 then return 1 end return 0 end

becomes:

s(:defn, :conditional1, s(:args, :arg1), s(:scope, s(:block, s(:if, s(:call, s(:lvar, :arg1), :==, s(:arglist, s(:lit, 0))), s(:return, s(:lit, 1)), nil), s(:return, s(:lit, 0)))))

Changes:

2.0.2 / 2009-01-20

  • 2 minor enhancements:

    • Added gauntlet_rubyparser plugin. YAY for easy massive bug-hunting.
    • Promoted Sexp's file/line/comments to sexp_processor.
  • 4 bug fixes:

    • Fixed and improved the readme
    • Fixed lexing heredoc newlines.
    • Fixed line numbers on defns.
    • Fixed rdoc generation bug pointed out by hugh sasse (who rocks)
  • http://parsetree.rubyforge.org/

Gauntlet Kicks Ass

| | Comments (0)
% gauntlet report parsetree
 47369 93.73% good
  2011  3.98% bad
  1160  2.30% skip
...
% gauntlet parse_tree
...
keyword_prospector-0.8.1
  setup.rb: good
  ALL GOOD!
kickstart-0.2.2.1
  lib/extentions/array.rb: good
  lib/extentions/class.rb: bad
KirbyBase-2.6
  lib/kirbybase.rb: bad
...

the fact that I can incrementally fix something and then run it against the known failures makes doing compatibility work via gauntlet pure joy. I've been using gauntlet to compare parsetree to rubyparser and to do round trips between rubyparser and ruby2ruby. It's finding _a lot of stuff for me to work on.

ruby_parser (RP) is a ruby parser written in pure ruby (utilizing racc--which does by default use a C extension). RP's output is the same as ParseTree's output: s-expressions using ruby's arrays and base types.

Changes:

2.0.1 / 2008-11-04

  • 2 minor enhancements:

    • Updated for changes to splat node in many contexts.
    • Made PT a developer dep
  • http://rubyforge.org/projects/parsetree/

About this Archive

This page is a archive of recent entries in the ruby_parser category.

ruby2ruby is the previous category.

sexp_processor is the next category.

Find recent content on the main index or look in the archives to find all content.

Pages

Powered by Movable Type 4.32-en