[ANN] ParseTree 1.0.0 Released

R

Ryan Davis

ParseTree version 1.0.0 has been released!

http://www.zenspider.com/ZSS/Products/ParseTree/

** DESCRIPTION:

ParseTree is a C extension (using RubyInline) that extracts the parse
tree for an entire class or a specific method and returns it as a
s-expression (aka sexp) using ruby's arrays, strings, symbols, and
integers.

As an example:

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

becomes:

[:defn,
"conditional1",
[:scope,
[:block,
[:args, "arg1"],
[:if,
[:call, [:lvar, "arg1"], "==", [:array, [:lit, 0]]],
[:return, [:lit, 1]],
nil],
[:return, [:lit, 0]]]]]

** FEATURES/PROBLEMS:

+ Uses RubyInline, so it just drops in.
+ Includes show.rb, which lets you quickly snoop code.
+ Includes abc.rb, which lets you get abc metrics on code.
+ abc metrics = # of assignments, branches, and calls
+ whitespace independent metric for method complexity.
+ Only works on methods in classes/modules, not arbitrary code.
+ Does not work on the core classes, as they are not ruby (yet).

http://www.zenspider.com/ZSS/Products/ParseTree/

Changes:

+ 1 major enhancement
+ Birthday!

http://www.zenspider.com/ZSS/Products/ParseTree/
 
L

Lothar Scholz

Hello Ryan,

RD> ParseTree version 1.0.0 has been released!

RD> http://www.zenspider.com/ZSS/Products/ParseTree/

RD> ** DESCRIPTION:

Thanks for the release.

Can you tell me why the following nodes don't have a corresponding
element in the result tree ? Are they not used anymore in the ruby
interpreter ?

case NODE_BLOCK_ARG:
case NODE_SELF:
case NODE_NIL:
case NODE_TRUE:
case NODE_FALSE:
case NODE_ZSUPER:
case NODE_BMETHOD:
case NODE_REDO:
case NODE_RETRY:
case NODE_COLON3:
case NODE_NTH_REF:
case NODE_BACK_REF:
case NODE_ZARRAY:
case NODE_XSTR:
case NODE_UNDEF:
case NODE_ALIAS:
case NODE_VALIAS:
 
E

Eric Hodel

Hello Ryan,

RD> ParseTree version 1.0.0 has been released!

RD> http://www.zenspider.com/ZSS/Products/ParseTree/

RD> ** DESCRIPTION:

Thanks for the release.

Can you tell me why the following nodes don't have a corresponding
element in the result tree ? Are they not used anymore in the ruby
interpreter ?

case NODE_BLOCK_ARG:
case NODE_SELF:
case NODE_NIL:
case NODE_TRUE:
case NODE_FALSE:
case NODE_ZSUPER:
case NODE_BMETHOD:
case NODE_REDO:
case NODE_RETRY:
case NODE_COLON3:
case NODE_NTH_REF:
case NODE_BACK_REF:
case NODE_ZARRAY:
case NODE_XSTR:
case NODE_UNDEF:
case NODE_ALIAS:
case NODE_VALIAS:

The comment just above explains most of it:

// these are things we know we do not need to translate to C.

The goals we originally had for ParseTree didn't need any of those
nodes (even though true, nil, and false work ok) for what we were
doing. We quickly realized how useful ParseTree could be beyond what
we were using it for, so launched it as a separate project.

If you run some code through show with the equivalents of those nodes,
they simply end up as empty nodes. If you need those nodes, you could
simply fill in the proper C code to extract them, then send us a patch.

$ cat x.rb
class X
def foo
::X
nil
true
false
super
[]
self
end
end
$ parse_tree_show x.rb
/x.rb:3: warning: useless use of :: in void context
/x.rb:4: warning: useless use of nil in void context
/x.rb:5: warning: useless use of true in void context
/x.rb:6: warning: useless use of false in void context
[[:defn,
"foo",
[:scope,
[:block,
[:args],
[:colon3],
[:nil],
[:true],
[:false],
[:zsuper],
[:zarray],
[:self]]]]]
 
L

Lothar Scholz

Hello Eric,


EH> The comment just above explains most of it:

EH> // these are things we know we do not need to translate to C.

EH> The goals we originally had for ParseTree didn't need any of those
EH> nodes (even though true, nil, and false work ok) for what we were
EH> doing. We quickly realized how useful ParseTree could be beyond what
EH> we were using it for, so launched it as a separate project.

EH> If you run some code through show with the equivalents of those nodes,
EH> they simply end up as empty nodes. If you need those nodes, you could
EH> simply fill in the proper C code to extract them, then send us a patch.

Okay thanks this was not clear from the comment.

But shouldn't they available now you have outsourced the code to this
project. When i read "parsetree" together with a 1.0 version i would
expect that it gives me a complete reverseable tree representation.

And another question, shouldn't "super" (which is among the omitted
nodes) count as 1 in the abc metrics ?
 
B

Brian Wisti

After looking at the various software packages out there including open
source and closed, public domain and commercial), I've come to the
conclusion that version numbering is pretty much arbitrary. I think
when a Zen* package comes out, they mark it as "1.0" because it is now
good enough to do what they'd intended it to, and it has been released
so the rest of us can take a look.

Kind Regards,

Brian Wisti
http://coolnamehere.com/
 
R

Ryan Davis

But shouldn't they available now you have outsourced the code to this
project. When i read "parsetree" together with a 1.0 version i would
expect that it gives me a complete reverseable tree representation.

I'm sorry we didn't meet your expectations of quality on a dot-oh
release. Please remember that this is an open-source _free_ software
release. We welcome _constructive_ criticism as well as patches.
And another question, shouldn't "super" (which is among the omitted
nodes) count as 1 in the abc metrics ?

Yes, it probably should. I'll make that change now.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top