Professional Web Applications Themes

Ruby to Parrot compiler - Ruby

Is there anyone working on a compiler for compiling Ruby code to work on parrot? The latest effort Cardinal seemed to die off before it got started, presumably due to the immaturity of Parrot. However version 0.1.0 of Parrot is set to be released on the 29th of this month wich should include support for objects, so this seems to be the ideal time to get a compiler project started up. Cardinal was set up on Savannah but this seems to be a perfect project to start up on Rubyforge. Is anyone else interested in this? Best Regards Mark Sparshatt...

  1. #1

    Default Ruby to Parrot compiler

    Is there anyone working on a compiler for compiling Ruby code to work on
    parrot?

    The latest effort Cardinal seemed to die off before it got started,
    presumably due to the immaturity of Parrot.

    However version 0.1.0 of Parrot is set to be released on the 29th of
    this month wich should include support for objects, so this seems to be
    the ideal time to get a compiler project started up.

    Cardinal was set up on Savannah but this seems to be a perfect project
    to start up on Rubyforge.

    Is anyone else interested in this?

    Best Regards

    Mark Sparshatt



    Mark Guest

  2. #2

    Default Re: Ruby to Parrot compiler

    il Fri, 20 Feb 2004 04:45:37 +0900, Mark <co.uk> ha
    scritto::

     

    I'd love to see that, but I really don't think I can help ,even if dan
    sugalsky says that compilers are easy[1] :)
    PDD 15 (objects) is done IIRC , so a ruby compiler could be started
    prolly :)


    http://www.sidhe.org/~dan/blog/archives/000304.html


    gabriele Guest

  3. #3

    Default Re: Ruby to Parrot compiler

    Mark <co.uk> wrote in message news:<co.uk>... 

    So they're promising object support at the end of the month? I've
    heard this for almost two years now. I'll believe it when I see it.
     

    I'm very interested in this. I was the one who setup the project at
    Savannah (now I don't even know where I put the passwords for it, it's
    been so long ago). I definately want to see a Ruby front-end for
    Parrot. Back when I started the project I wasn't working. Since then
    I've been going to grad school and more recently I've gotten a job and
    I'm still going to grad school so I really don't have a lot of time to
    commit to this.

    Please feel free start a Cardinal project on Rubyforge. Even if
    Object support in Parrot doesn't come out this month, it will
    _eventually_ happen(at least I hope so :). In the meantime there are
    lots of other tasks that could be done. The foremost being that we
    need a good pr for Ruby (Cardinal isn't the only project that
    needs this). I just saw another post that mentioned Ripper again.
    Might be worth a try. There's also Ruth. At any rate, I think the
    main focus right now needs to be on the frontend until the backend
    issues (object support in Parrot) are ironed out.

    Phil
    Phil Guest

  4. #4

    Default Re: Ruby to Parrot compiler

    Chad Fowler wrote:
     
    Thanks for the suggestion. I've downloaded the tarball of the cvs files
    and started experimenting with it.

    From what I've seen it does seem to be close to what we need. Once it's
    finished it seems that in order to build a compiler all you'd have to do
    is subclass the Ripper class and add in callbacks that output the
    correct code.

    I'll try to help with Ripper thoughmy C skills are rather rusty so I'm
    not sure how much I'll be able to help.

    --

    Mark Sparshatt



    Mark Guest

  5. #5

    Default Re: Ruby to Parrot compiler

    Phil Tomson wrote:
     
    >
    >So they're promising object support at the end of the month? I've
    >heard this for almost two years now. I'll believe it when I see it.
    >
    >
    >[/ref]
    AFAIK, The spec for the object support has been written and Dan has
    promised to check a basic implementation in to the source tree in time
    for the feature freeze monday.
     
    >
    >I'm very interested in this. I was the one who setup the project at
    >Savannah (now I don't even know where I put the passwords for it, it's
    >been so long ago). I definately want to see a Ruby front-end for
    >Parrot. Back when I started the project I wasn't working. Since then
    >I've been going to grad school and more recently I've gotten a job and
    >I'm still going to grad school so I really don't have a lot of time to
    >commit to this.
    >
    >Please feel free start a Cardinal project on Rubyforge. Even if
    >Object support in Parrot doesn't come out this month, it will
    >_eventually_ happen(at least I hope so :). In the meantime there are
    >lots of other tasks that could be done. The foremost being that we
    >need a good pr for Ruby (Cardinal isn't the only project that
    >needs this). I just saw another post that mentioned Ripper again.
    >Might be worth a try. There's also Ruth. At any rate, I think the
    >main focus right now needs to be on the frontend until the backend
    >issues (object support in Parrot) are ironed out.
    >
    >
    >[/ref]
    I've tried out Ripper and it seems to be very close to what we need for
    a front end. Though I'll also take a look at Ruth.

    There are AFAIK at least two projects that convert Ruby code into
    bytecode, I wonder how easy it would be to modify them so they emit
    parrot bytecode? I admit I'm not clear about how they work.

    I agree that the front end is the best place to start working on the
    project.

    --
    Mark Sparshatt



    Mark Guest

  6. #6

    Default Re: Ruby to Parrot compiler

    Mark wrote:
     
    >>
    >>
    >> So they're promising object support at the end of the month? I've
    >> heard this for almost two years now. I'll believe it when I see it.
    >>
    >>
    >>[/ref]
    > AFAIK, The spec for the object support has been written and Dan has
    > promised to check a basic implementation in to the source tree in time
    > for the feature freeze monday.

    >>
    >>
    >> I'm very interested in this. I was the one who setup the project at
    >> Savannah (now I don't even know where I put the passwords for it, it's
    >> been so long ago). I definately want to see a Ruby front-end for
    >> Parrot. Back when I started the project I wasn't working. Since then
    >> I've been going to grad school and more recently I've gotten a job and
    >> I'm still going to grad school so I really don't have a lot of time to
    >> commit to this.
    >>
    >> Please feel free start a Cardinal project on Rubyforge. Even if
    >> Object support in Parrot doesn't come out this month, it will
    >> _eventually_ happen(at least I hope so :). In the meantime there are
    >> lots of other tasks that could be done. The foremost being that we
    >> need a good pr for Ruby (Cardinal isn't the only project that
    >> needs this). I just saw another post that mentioned Ripper again.
    >> Might be worth a try. There's also Ruth. At any rate, I think the
    >> main focus right now needs to be on the frontend until the backend
    >> issues (object support in Parrot) are ironed out.
    >>
    >>
    >>[/ref]
    > I've tried out Ripper and it seems to be very close to what we need
    > for a front end. Though I'll also take a look at Ruth.
    >[/ref]
    Does anyone know where I can find Ruth? I've tried looking on Rubyforge
    and RAA but haven't been able to find it.

    Thanks in Advance.
     



    Mark Guest

  7. #7

    Default Re: Ruby to Parrot compiler


    On Feb 20, 2004, at 10:51 AM, Mark wrote:
     

    It is part of the RubyVM project, on sourceforge.
    http://sourceforge.net/project/showfiles.php?group_id=26000



    Mark Guest

  8. #8

    Default Re: Ruby to Parrot compiler (where is Ruth?)

    In article <com>,
    Mark Hubbart <com> wrote: 
    >
    >It is part of the RubyVM project, on sourceforge.
    >http://sourceforge.net/project/showfiles.php?group_id=26000
    >
    >
    >[/ref]

    But that appears to be an old version. A newer version was announced last
    August (http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/79936)
    but it's not available at the location given in that link.

    Phil

    Phil Guest

  9. #9

    Default Re: Ruby to Parrot compiler (where is Ruth?)


    "Phil Tomson" wrote: 
    > >
    > >It is part of the RubyVM project, on sourceforge.
    > >http://sourceforge.net/project/showfiles.php?group_id=26000
    > >[/ref]
    >
    > But that appears to be an old version. A newer version was announced last
    > August (http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/79936)
    > but it's not available at the location given in that link.
    >
    > Phil
    >[/ref]

    Still temporary, but this worked just now.

    V 0.10

    http://www.pronovomundo.com/ruth/


    daz



    daz Guest

  10. #10

    Default Re: Ruby to Parrot compiler (where is Ruth?)

    daz wrote:
     
    >>But that appears to be an old version. A newer version was announced last
    >>August (http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/79936)
    >>but it's not available at the location given in that link.
    >>
    >>Phil
    >>
    >>
    >>[/ref]
    >
    >Still temporary, but this worked just now.
    >
    >V 0.10
    >
    >http://www.pronovomundo.com/ruth/
    >
    >
    >
    >[/ref]
    Thanks, that link works. Though the file linked there is misnamed. It
    has the extension .tar.gz even though it's just a tar file.

    It seems that the choice for a front end is between Ripper and Ruth.
    Both'll need a bit of development before they can be used, and neither
    is doented.

    Personally I think Ruth is the better choice since it has fewer
    dependencies (Ripper needs bison and gperf) and it's interface seems to
    be simpler.

    Though it has the problem that when parsing a method definition using
    the standard p method there's no way to find out what parameters the
    methods takes. However I think there might be lower level methods which
    can be used in this case.


    ISTM the best bet would be to design the compiler so that the pr can
    be swapped easily. Looking at the archives for Cardinal I noticed there
    was talk of Rite having a seperate pr component. Being able to use
    that as a pr would be very useful.


    I'm going to set up a project on Rubyforge in order to work on this.

    --
    Mark Sparshatt



    Mark Guest

  11. #11

    Default Re: Ruby to Parrot compiler (where is Ruth?)

    On Saturday 21 February 2004 08:24, daz wrote: 

    patch to make it compile for my 1.8.1.

    diff -uir ruth-0.10/ext/ruby/interpreter/node_specifications.rb
    ruth-0.10-mod/ext/ruby/interpreter/node_specifications.rb
    --- ruth-0.10/ext/ruby/interpreter/node_specifications.rb 2003-08-22
    14:37:49.000000000 +0200
    +++ ruth-0.10-mod/ext/ruby/interpreter/node_specifications.rb 2004-02-21
    12:58:25.000000000 +0100
    -121,8 +121,8
    if RUBY_VERSION >= "1.7"
    # REXPAND seems not to be in Ruby 1.8 anymore as of 2003-04-15
    # NODE_SPECIFICATIONS["REXPAND"] = [[:head, :RNode]]
    - NODE_SPECIFICATIONS["RESTARY"] = [[:head, :RNode]]
    - NODE_SPECIFICATIONS["RESTARY2"] = [[:head, :RNode]]
    + # NODE_SPECIFICATIONS["RESTARY"] = [[:head, :RNode]]
    + # NODE_SPECIFICATIONS["RESTARY2"] = [[:head, :RNode]]
    NODE_SPECIFICATIONS["SVALUE"] = [[:head, :RNode]]
    NODE_SPECIFICATIONS.delete "CVAR2"
    NODE_SPECIFICATIONS.delete "RESTARGS"

    Alex

    --
    Death wish, n.:
    The only wish that always comes true, whether or not one wishes it to.


    Alexander Guest

  12. #12

    Default Re: Ruby to Parrot compiler (where is Ruth?)

    daz wrote:
     
    Oops, I never updated that page. Anyway that's the latest released
    version. I've had a couple of bug reports which are in the pipe.

    Regards,

    Robert





    Robert Guest

  13. #13

    Default Re: Ruby to Parrot compiler (where is Ruth?)

    Mark wrote:
     
    On Ruby prs I might also mention that the new version of Rockit
    (that I've used internally in my research for some time) has a Ruby
    pr. Rockit's new model is to automatically generate an AST-builder
    class that builds an AST for you when parsing. If you want your own
    callbacks without building the AST you can just subclass or write your
    own builder class and initialize the pr class with that. It seems to
    be a fairly good compromise between the different parsing "styles". I
    have planned to release it for long but it has some non-open code that I
    need to get rid of. I've sat dates before so I won't do that again
    though so you might be better off with something else for now... ;)

    Anyway, the idea is that both Ruth and Rockit's Ruby pr should
    generate the same AST so that they can be tested against each other for
    conformance.

    /Robert





    Robert Guest

  14. #14

    Default Re: Ruby to Parrot compiler

    Hi.
    This is probably naive, but I was wondering why you couldn't just use Ruby's
    existing front-end implementation to p and build an AST, and then build
    a seperate generator that takes the AST as input to compile and emit Parrot
    VM code? I haven't looked at Ruby's implementation, so I don't know how it
    was designed, but if it was designed to seperate concerns: tokenizing,
    parsing, semantic checking, optimization, etc., then as long as you know
    what each part returns, you should be able to build new components for each
    stage. In this case, you'd want to build a new Parrot code generator that
    takes the AST that Ruby currently creates when interpreting a program
    (assuming Ruby creates an AST, of course). You might also be able to make a
    generator for .NET in this way ... Anyway. I was just thinking you could
    leverage the existing code, and save some time and effort. But, perhaps what
    I'm saying can't be done - or can't be done using Ruby's existing C
    implementation. Just an idea.

    Sean


    Sean Guest

  15. #15

    Default Re: Ruby to Parrot compiler

    On Sat, 21 Feb 2004 09:54:25 -0500, Sean Ross wrote: 
    [snip]

    Cool.. a ruby2ast converter.

    Question: is the AST a bunch of ruby classes, which can be
    manipulated/navigated through Ruby?


    One day, I hope, to extend my editor so it can interact with Rubys AST,
    then some really nice things becomes possible:

    * advanced syntax coloring which can identify syntax-errors.
    * obtain advanced help about the code under the cursor.
    * advanced code completion.


    --
    Simon Strandgaard

    Simon Guest

  16. #16

    Default Re: Ruby to Parrot compiler (where is Ruth?)

    Robert Feldt wrote: 
    > On Ruby prs I might also mention that the new version of Rockit
    > (that I've used internally in my research for some time) has a Ruby
    > pr. Rockit's new model is to automatically generate an AST-builder
    > class that builds an AST for you when parsing. If you want your own
    > callbacks without building the AST you can just subclass or write your
    > own builder class and initialize the pr class with that. It seems to
    > be a fairly good compromise between the different parsing "styles". I
    > have planned to release it for long but it has some non-open code that I
    > need to get rid of. I've sat dates before so I won't do that again
    > though so you might be better off with something else for now... ;)
    >
    > Anyway, the idea is that both Ruth and Rockit's Ruby pr should
    > generate the same AST so that they can be tested against each other for
    > conformance.
    >
    > /Robert
    >
    >
    >
    >
    >[/ref]

    How hard is it to just piggyback on top of p.y from the ruby source?
    Or does a lot of evaluation take place still in that file. You could
    however just change what each of the actions to do to match your
    backend. Unless you want the byte-code compiler to be entirely self
    hosting of course. But if Rocket depends on bison anyhow you don't get
    anyway.

    I guess the problem I am seeing with the parrot compiler is all the code
    that is C-calls into the interpreter. How do you plan on keeping that
    ability, while adding the benefit of parrot? I'm curious how the
    interop works with parrot.

    Another point is that while I think this is a great idea, maybe we
    should push to get a Rite compiler working, but make it have some sort
    of pluggable middle/backend so that we can drop out bytecode or just
    interpret in C. It just seems awkward to rush ahead and get a bytecode
    compiler for a bytecode platform that hasn't completely standardized,
    just before the language your compiling is going through a standards
    change that may break code.

    Just my 2 cents,
    Charles Comstock
    Charles Guest

  17. #17

    Default Re: Ruby to Parrot compiler

    Simon Strandgaard wrote:
     
    >
    > [snip]
    >
    > Cool.. a ruby2ast converter.
    >
    > Question: is the AST a bunch of ruby classes, which can be
    > manipulated/navigated through Ruby?
    >
    >
    > One day, I hope, to extend my editor so it can interact with Rubys AST,
    > then some really nice things becomes possible:
    >
    > * advanced syntax coloring which can identify syntax-errors.
    > * obtain advanced help about the code under the cursor.
    > * advanced code completion.
    >
    >
    > --
    > Simon Strandgaard
    >[/ref]

    I think we definitely need a meta-aware ruby interpreter that you can
    hook some stuff when it's parsing it's own file. Or even just an
    interpreter switch that dumps the p tree in a couple of different
    formats, if it's too hard to get it at runtime. This would make it much
    easier for alot of things.

    Charles Comstock
    Charles Guest

  18. #18

    Default Re: Ruby to Parrot compiler (where is Ruth?)

    Charles Comstock wrote:
     
    >> On Ruby prs I might also mention that the new version of Rockit
    >> (that I've used internally in my research for some time) has a Ruby
    >> pr. Rockit's new model is to automatically generate an
    >> AST-builder class that builds an AST for you when parsing. If you
    >> want your own callbacks without building the AST you can just
    >> subclass or write your own builder class and initialize the pr
    >> class with that. It seems to be a fairly good compromise between the
    >> different parsing "styles". I have planned to release it for long but
    >> it has some non-open code that I need to get rid of. I've sat dates
    >> before so I won't do that again though so you might be better off
    >> with something else for now... ;)
    >>
    >> Anyway, the idea is that both Ruth and Rockit's Ruby pr should
    >> generate the same AST so that they can be tested against each other
    >> for conformance.
    >>
    >> /Robert
    >>
    >>
    >>
    >>
    >>[/ref]
    >
    > How hard is it to just piggyback on top of p.y from the ruby
    > source? Or does a lot of evaluation take place still in that file.
    > You could however just change what each of the actions to do to match
    > your backend. Unless you want the byte-code compiler to be entirely
    > self hosting of course. But if Rocket depends on bison anyhow you
    > don't get anyway.
    >[/ref]
    Ripper uses p.y to generate it pr, so it is possible.
     
    I'm not sure that I follow you here.

    Do you mean how to handle the eval instruction? In parrot there's an
    opcode that registers a function as being a compiler. then another
    opcode is used to compile a string to bytecode.

    If you mean how to call code written in c there's the NCI interface
    which so far has been used to create parrot bindings to PostgreSQL and SDL
     
    My understanding is that Matz isn't going to release Rite until it is at
    a stage where it is running reasonably. I'm not sure how we can push to
    get Rite working till then.

    I like the idea of having a plugable back end to the Rite compiler so it
    would be possible to get it to target the Rite Vm, Parrot, .net or the JVM.

    Still even if this project is supersceded by Rite, I think it would at
    least make a good prototype.

    --
    Mark Sparshatt



    Mark Guest

  19. #19

    Default Re: Ruby to Parrot compiler

    Charles Comstock wrote:
     
    >>
    >>
    >> [snip]
    >>
    >> Cool.. a ruby2ast converter.
    >>
    >> Question: is the AST a bunch of ruby classes, which can be
    >> manipulated/navigated through Ruby?
    >>
    >>
    >> One day, I hope, to extend my editor so it can interact with Rubys
    >> AST, then some really nice things becomes possible:
    >>
    >> * advanced syntax coloring which can identify syntax-errors.
    >> * obtain advanced help about the code under the cursor.
    >> * advanced code completion.
    >>
    >>
    >> --
    >> Simon Strandgaard
    >>[/ref]
    >
    > I think we definitely need a meta-aware ruby interpreter that you can
    > hook some stuff when it's parsing it's own file. Or even just an
    > interpreter switch that dumps the p tree in a couple of different
    > formats, if it's too hard to get it at runtime. This would make it
    > much easier for alot of things.
    >[/ref]
    This sounds like a Ruby version of Perls B::** modules, which I agree
    would be a very good thing.

    Though would it be best to do this by modifying the interpreter, or by
    using one of Ripper, Ruth or Rocket?

    --

    Mark Sparshatt



    Mark Guest

  20. #20

    Default Re: Ruby to Parrot compiler

    il Sat, 21 Feb 2004 09:54:25 -0500, "Sean Ross"
    <carleton.ca> ha scritto::
     

    I think this is what ruth , bytecoderuby and YAPV do.
    ripper, OTOH, uses ruby's p.y 

    gabriele Guest

Page 1 of 2 12 LastLast

Similar Threads

  1. Ruby for Windows, Compiler (like DJGPP)
    By Legion in forum Ruby
    Replies: 3
    Last Post: December 21st, 03:48 PM
  2. [Rite] Byte-Code Compiler in Ruby
    By Michael Neumann in forum Ruby
    Replies: 3
    Last Post: November 17th, 11:03 AM
  3. Parrot SMOP benchmark
    By Harry Ohlsen in forum Ruby
    Replies: 10
    Last Post: August 5th, 12:50 PM
  4. Parrot and Ruby
    By robert ehteshamzadeh in forum Ruby
    Replies: 1
    Last Post: July 12th, 07:19 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139