[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Ripper and Ruby 1.8

Jonathan Maasland

8/20/2006 11:07:00 AM

Hi all,

For the past two days I've been trying to get Ripper to compile with
Ruby 1.8
After searching and semi-translating some Japanese messages [1] with
Babelfish I managed to compile Ripper for 1.8 but when using it I get an
error-message: [Ripper - FATAL] : Unknown token 357 (or something like that)

Does anyone here have experience with getting Ripper working under 1.8?
Does anyone know the specifics as to why Ripper states it needs 1.9?
Does it have to do with parse.y?

Any information on the subject is really really appreciated.

With kind regards,
Jonathan


[1] : http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby...

14 Answers

Nobuyoshi Nakada

8/20/2006 12:22:00 PM

0

Hi,

At Sun, 20 Aug 2006 20:07:16 +0900,
Jonathan Maasland wrote in [ruby-talk:209477]:
> Does anyone know the specifics as to why Ripper states it needs 1.9?
> Does it have to do with parse.y?

Ripper needs bison, but 1.8 can be compiled with other yaccs.

--
Nobu Nakada

Jonathan Maasland

8/20/2006 3:40:00 PM

0

nobu@ruby-lang.org wrote:

>Hi,
>
>
>Ripper needs bison, but 1.8 can be compiled with other yaccs.
>
>
Thanks for the reply but I'm a bit at a loss here. I'm a total noob
regarding Ruby's compilation process so I'm sorry if this is a stupid
question but if I have bison available why should I not be able to
compile Ripper against 1.8?

Thanks,
Jonathan

Dominik Bathon

8/20/2006 5:52:00 PM

0

Hi,

On Sun, 20 Aug 2006 17:39:40 +0200, Jonathan Maasland <nochoice@xs4all.n=
l> =

wrote:

> Thanks for the reply but I'm a bit at a loss here. I'm a total noob =

> regarding Ruby's compilation process so I'm sorry if this is a stupid =
=

> question but if I have bison available why should I not be able to =

> compile Ripper against 1.8?

I don't know how to get Ripper working, but depending on what you want t=
o =

do, there might be better solutions like RubyNode or ParseTree.

For example with RubyNode (http://rubynode.ruby...) you can do:

>> pp "3.times { puts 'Ruby' }".parse_to_nodes.transform
[:iter,
{:var=3D>false,
:iter=3D>[:call, {:args=3D>false, :mid=3D>:times, :recv=3D>[:lit, {:l=
it=3D>3}]}],
:body=3D>[:fcall, {:args=3D>[:array, [[:str, {:lit=3D>"Ruby"}]]], =

:mid=3D>:puts}]}]
=3D> nil

The only thing that RubyNode or ParseTree won't give you are the comment=
s =

and whitespace in the code.


Dominik

Jonathan Maasland

8/20/2006 6:38:00 PM

0

Dominik Bathon wrote:

>
> I don't know how to get Ripper working, but depending on what you want
> to do, there might be better solutions like RubyNode or ParseTree.
>
> --snip--

It's what we currently use in FreeRIDE and I kinda like the way Ripper
is used. Currently we only use it to aquire all methods/modules/classes.
I guess I could look into working with a different parser but I'd prefer
Ripper.

> The only thing that RubyNode or ParseTree won't give you are the
> comments and whitespace in the code.

That's a bit of a letdown, nothing too serious. Probably easy to work
around by wrapping the IO-source.
Do you have any idea as to how memory-intensive either are?

Anyhow, thanks for the suggestion. I'll look into it if Ripper takes too
long to get running again.

Jonathan

Dominik Bathon

8/20/2006 8:08:00 PM

0

On Sun, 20 Aug 2006 20:37:58 +0200, Jonathan Maasland <nochoice@xs4all.n=
l> =

wrote:

> Dominik Bathon wrote:
>
>>
>> I don't know how to get Ripper working, but depending on what you wan=
t =

>> to do, there might be better solutions like RubyNode or ParseTree.
>>
>> --snip--
>
> It's what we currently use in FreeRIDE and I kinda like the way Ripper=
=

> is used. Currently we only use it to aquire all methods/modules/classe=
s. =

> I guess I could look into working with a different parser but I'd pref=
er =

> Ripper.

Ah okay, I thought you were trying to get Ripper running for the first =

time, for a new project. If you already have code then it might be easie=
r =

to get Ripper working.

Anyway, here is some basic code to get methods and classes with RubyNode=
=

(it's really basic and doesn't work with nested classes, just to get you=
=

started):

Lets say we have this file:

$ cat test.rb
class A
def a
1
end
def b
2
end
end

class B
def c
3
end
end

Then this code:

require "rubynode"
require "pp"

tree =3D IO.read("test.rb").parse_to_nodes.transform

def statements(block_or_single_node)
if block_or_single_node.first =3D=3D :block
block_or_single_node.last
else
[block_or_single_node] # only one statement
end
end

statements(tree).each { |s|
if s.first =3D=3D :class
p s.last[:cpath]
statements(s.last[:body].last[:next]).each { |d|
if d.first =3D=3D :defn
p d.last[:mid]
pp d.last[:defn]
end
}
end
}

outputs:

[:colon2, {:mid=3D>:A, :head=3D>false}]
:a
[:scope,
{:rval=3D>false,
:tbl=3D>nil,
:next=3D>
[:block, [[:args, {:cnt=3D>0, :opt=3D>false, :rest=3D>-1}], [:lit, =

{:lit=3D>1}]]]}]
:b
[:scope,
{:rval=3D>false,
:tbl=3D>nil,
:next=3D>
[:block, [[:args, {:cnt=3D>0, :opt=3D>false, :rest=3D>-1}], [:lit, =

{:lit=3D>2}]]]}]
[:colon2, {:mid=3D>:B, :head=3D>false}]
:c
[:scope,
{:rval=3D>false,
:tbl=3D>nil,
:next=3D>
[:block, [[:args, {:cnt=3D>0, :opt=3D>false, :rest=3D>-1}], [:lit, =

{:lit=3D>3}]]]}]


>> The only thing that RubyNode or ParseTree won't give you are the =

>> comments and whitespace in the code.
>
> That's a bit of a letdown, nothing too serious. Probably easy to work =
=

> around by wrapping the IO-source.
> Do you have any idea as to how memory-intensive either are?

They both wrap Ruby's internal NODEs. ParseTree converts them into =

s-expressions (nested arrays), RubyNode's transform converts them to =

something similar (see above, a mix of arrays and hashes). So they use a=
s =

much memory as their output needs.

If you really want to avoid the transformation to s-expressions then you=
=

can use RubyNodes directly without calling transform (see documentation)=
, =

but that usually shouldn't be necessary.

And btw. if you want to get the nodes without evaling the code then you =
=

currently have to use RubyNode, ParseTree doesn't support that (yet).

Dominik

Nobuyoshi Nakada

8/21/2006 2:05:00 AM

0

Hi,

At Mon, 21 Aug 2006 00:39:40 +0900,
Jonathan Maasland wrote in [ruby-talk:209505]:
> Thanks for the reply but I'm a bit at a loss here. I'm a total noob
> regarding Ruby's compilation process so I'm sorry if this is a stupid
> question but if I have bison available why should I not be able to
> compile Ripper against 1.8?

Ripper needs a bison specific feature, but parse.y in 1.8 can't
and doesn't use it due to the compatibility.

--
Nobu Nakada

Kickin' Ass and Takin' Names

5/22/2013 5:25:00 PM

0

On Wed, 22 May 2013 09:45:37 -0500, "Lee" <cleetiss@gmail.com> wrote:

>Tracey12 wrote:
>
>>
>>
>> Rush is right. Lesbians aka radical feminists aka Feminazis are
>> disgusting and should be shouted down for the harm they are doing to
>> femininity.
>>
>> "Ugly women" are not necessarily physically ugly. But, the philosophy
>> of radical feminists is very very ugly and destructive to all women.
>>
>
>
> Jodie Foster is ugly? Really?

Ths is what turns on a rightwingerdinger:
http://www.thehollywoodgossip.com/gallery/sarah-palin...



>
>
>http://www.foxnews.com/entertainment/2013/01/14/jodie-foster-r...
>-suggests-retiring/
>
>
>

dzweibach

5/22/2013 6:23:00 PM

0

"Lee" <cleetiss@gmail.com> wrote:
> Tracey12 wrote:
>
> >
> >
> > Rush is right. Lesbians aka radical feminists aka Feminazis are
> > disgusting and should be shouted down for the harm they are doing to
> > femininity.
> >
> > "Ugly women" are not necessarily physically ugly. But, the philosophy
> > of radical feminists is very very ugly and destructive to all women.
> >
>
> Jodie Foster is ugly? Really?
>
> http://www.foxnews.com/entertainment/2013/01/14/jodie-foster-r...
> -suggests-retiring/

LOL! great response.

George Kerby

5/22/2013 8:43:00 PM

0




On 5/22/13 9:45 AM, in article
KradnRWV0aWMRwHMnZ2dnUVZ_h6dnZ2d@giganews.com, "Lee" <cleetiss@gmail.com>
wrote:

> Tracey12 wrote:
>
>>
>>
>> Rush is right. Lesbians aka radical feminists aka Feminazis are
>> disgusting and should be shouted down for the harm they are doing to
>> femininity.
>>
>> "Ugly women" are not necessarily physically ugly. But, the philosophy
>> of radical feminists is very very ugly and destructive to all women.
>>
>
>
> Jodie Foster is ugly? Really?
>
>
> http://www.foxnews.com/entertainment/2013/01/14/jodie-foster-r...
> -suggests-retiring/
>

His career high point was Coppertone when she was three. Since then, it has
all been a downhill runaway train wreck.

George Kerby

5/22/2013 8:51:00 PM

0




On 5/22/13 1:23 PM, in article 20130522142318.599$V6@newsreader.com, "Denny"
<dzweibach@REMOVEyahoo.com> wrote:

> "Lee" <cleetiss@gmail.com> wrote:
>> Tracey12 wrote:
>>
>>>
>>>
>>> Rush is right. Lesbians aka radical feminists aka Feminazis are
>>> disgusting and should be shouted down for the harm they are doing to
>>> femininity.
>>>
>>> "Ugly women" are not necessarily physically ugly. But, the philosophy
>>> of radical feminists is very very ugly and destructive to all women.
>>>
>>
>> Jodie Foster is ugly? Really?
>>
>> http://www.foxnews.com/entertainment/2013/01/14/jodie-foster-r...
>> -suggests-retiring/
>
> LOL! great response.

Ask your son, Denny-Boi.