[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Thinking of creating a small mini-language-interpreter using Ruby

Glenn Smith

5/1/2005 7:21:00 PM

Always something I've wanted to write - an interpreter of my own. Now
I'm not likely to produce the next 'Ruby', but the recent announcement
of Fu's 'TAO', and other languages, make me wonder if I could write
something similar. Just for me, so to speak. A bit of fun.

I did look at the possibility of going down the traditional route of
[F]Lex/Yacc[Bison] and 'C', but it would be nice to write it in Ruby.
Alright, it would be one interpreted language interpreting another,
but as I said, 'a bit of fun'. That's if two small children and a
scary wife allow me the time of course!!

I see there are ruby-lex and ruby-yacc modules on RAA - anybody used
these in anger and are they complete/good-enough?

Has anybody done this kind of thing before? Not being a) a genius, b)
Matz, or c) the owner of a fine beard, can anybody recommend any good
URL's/tutorials/perhaps even books?

I could grow a beard of course...



--

All the best
Glenn
Aylesbury, UK



11 Answers

Bill Guindon

5/1/2005 7:46:00 PM

0

On 5/1/05, Glenn Smith <glenn.ruby@gmail.com> wrote:
> Always something I've wanted to write - an interpreter of my own. Now
> I'm not likely to produce the next 'Ruby', but the recent announcement
> of Fu's 'TAO', and other languages, make me wonder if I could write
> something similar. Just for me, so to speak. A bit of fun.
>
> I did look at the possibility of going down the traditional route of
> [F]Lex/Yacc[Bison] and 'C', but it would be nice to write it in Ruby.
> Alright, it would be one interpreted language interpreting another,
> but as I said, 'a bit of fun'. That's if two small children and a
> scary wife allow me the time of course!!
>
> I see there are ruby-lex and ruby-yacc modules on RAA - anybody used
> these in anger and are they complete/good-enough?
>
> Has anybody done this kind of thing before? Not being a) a genius, b)
> Matz, or c) the owner of a fine beard, can anybody recommend any good
> URL's/tutorials/perhaps even books?

Brian Wisti just announced a new release of PageTemplate, you might
want to take a look at it.

I used an earlier version as a guide while building a mini language in
another (non Ruby) language. His code was easy to read, and it
covered the basics (looping, branching, etc.) I probably could have
built my own mini language without it, but his code definitely sped up
the process.

It's not using lex or yacc (or at least the old version wasn't), so it
may be too simplified for your needs, but that could also make it
easier to learn from.

* http://rubyforge.org/projects/pag...
* http://coolnamehere.com/products/pag...

> I could grow a beard of course...

Yeah, they're mutually exclusive, as building a language/parser is
likely to cause you to want to tear some hair out :)

> --
>
> All the best
> Glenn
> Aylesbury, UK
>
>


--
Bill Guindon (aka aGorilla)



Glenn Smith

5/1/2005 8:00:00 PM

0

On 5/1/05, Bill Guindon <agorilla@gmail.com> wrote:

> > I could grow a beard of course...
>
> Yeah, they're mutually exclusive, as building a language/parser is
> likely to cause you to want to tear some hair out :)

Ah - the hair is doing that on it's own!!



Charles Comstock

5/1/2005 8:04:00 PM

0

Glenn Smith wrote:
> Always something I've wanted to write - an interpreter of my own. Now
> I'm not likely to produce the next 'Ruby', but the recent announcement
> of Fu's 'TAO', and other languages, make me wonder if I could write
> something similar. Just for me, so to speak. A bit of fun.
>
> I did look at the possibility of going down the traditional route of
> [F]Lex/Yacc[Bison] and 'C', but it would be nice to write it in Ruby.
> Alright, it would be one interpreted language interpreting another,
> but as I said, 'a bit of fun'. That's if two small children and a
> scary wife allow me the time of course!!
>
> I see there are ruby-lex and ruby-yacc modules on RAA - anybody used
> these in anger and are they complete/good-enough?
>
> Has anybody done this kind of thing before? Not being a) a genius, b)
> Matz, or c) the owner of a fine beard, can anybody recommend any good
> URL's/tutorials/perhaps even books?
>
> I could grow a beard of course...
>
>
>

I wrote a small sequencing FSM language as a domain language in Ruby and
then wrote a racc parser to convert from a simpler syntax to the ruby
domain language. Racc takes a little bit to get used to but it works
quite well and the runtime is included with every ruby install.

Charlie

Jeremy Tregunna

5/1/2005 8:56:00 PM

0

On 1-May-05, at 3:20 PM, Glenn Smith wrote:

> I see there are ruby-lex and ruby-yacc modules on RAA - anybody used
> these in anger and are they complete/good-enough?

I've used racc before and its quite nice.

> Has anybody done this kind of thing before? Not being
> a) a genius

hardly that.

> b) Matz

last time I checked I wasn't Matz. :)

> c) the owner of a fine beard

Oh well, 2 out of 3 :)

> I could grow a beard of course...

:)

> Glenn

--
Jeremy Tregunna
jtregunna@blurgle.ca




Robert Klemme

5/2/2005 7:17:00 AM

0


"Glenn Smith" <glenn.ruby@gmail.com> schrieb im Newsbeitrag
news:e09ac119050501122011ecce08@mail.gmail.com...
> Always something I've wanted to write - an interpreter of my own. Now
> I'm not likely to produce the next 'Ruby', but the recent announcement
> of Fu's 'TAO', and other languages, make me wonder if I could write
> something similar. Just for me, so to speak. A bit of fun.
>
> I did look at the possibility of going down the traditional route of
> [F]Lex/Yacc[Bison] and 'C', but it would be nice to write it in Ruby.
> Alright, it would be one interpreted language interpreting another,
> but as I said, 'a bit of fun'. That's if two small children and a
> scary wife allow me the time of course!!
>
> I see there are ruby-lex and ruby-yacc modules on RAA - anybody used
> these in anger and are they complete/good-enough?
>
> Has anybody done this kind of thing before? Not being a) a genius, b)
> Matz, or c) the owner of a fine beard, can anybody recommend any good
> URL's/tutorials/perhaps even books?
>
> I could grow a beard of course...

The beard might help - but OTOH how will your scary wife react to that?
Might turn the whole thing into a mission impossible...
;-)

I haven't done this myself just a silly idea: when you compile your
language X right into Ruby code, then X might not be that slow during
execution because you save yourself one level of interpretation.

Kind regards

robert

Lyndon Samson

5/2/2005 8:17:00 AM

0

On 5/2/05, Robert Klemme <bob.news@gmx.net> wrote:
>
> "Glenn Smith" <glenn.ruby@gmail.com> schrieb im Newsbeitrag
> news:e09ac119050501122011ecce08@mail.gmail.com...
> > Always something I've wanted to write - an interpreter of my own. Now
> > I'm not likely to produce the next 'Ruby', but the recent announcement
> > of Fu's 'TAO', and other languages, make me wonder if I could write
> > something similar. Just for me, so to speak. A bit of fun.
> >
> > I did look at the possibility of going down the traditional route of
> > [F]Lex/Yacc[Bison] and 'C', but it would be nice to write it in Ruby.
> > Alright, it would be one interpreted language interpreting another,
> > but as I said, 'a bit of fun'. That's if two small children and a
> > scary wife allow me the time of course!!
> >
> > I see there are ruby-lex and ruby-yacc modules on RAA - anybody used
> > these in anger and are they complete/good-enough?
> >
> > Has anybody done this kind of thing before? Not being a) a genius, b)
> > Matz, or c) the owner of a fine beard, can anybody recommend any good
> > URL's/tutorials/perhaps even books?
> >
> > I could grow a beard of course...
>
> The beard might help - but OTOH how will your scary wife react to that?
> Might turn the whole thing into a mission impossible...
> ;-)
>
> I haven't done this myself just a silly idea: when you compile your
> language X right into Ruby code, then X might not be that slow during
> execution because you save yourself one level of interpretation.
>
Or even better, do like GCC and have switchable 'back-ends' that
generate for different execution environments ( ruby, python, perl,
java ) etc. :-)


> Kind regards
>
> robert
>
>


--
Into RFID? www.rfidnewsupdate.com Simple, fast, news.



Glenn Smith

5/2/2005 10:07:00 AM

0

Sounds like I need to craft a "Richard Stallman" style beard then!!


On 5/2/05, Lyndon Samson <lyndon.samson@gmail.com> wrote:
> On 5/2/05, Robert Klemme <bob.news@gmx.net> wrote:
> >
> > "Glenn Smith" <glenn.ruby@gmail.com> schrieb im Newsbeitrag
> > news:e09ac119050501122011ecce08@mail.gmail.com...
> > > Always something I've wanted to write - an interpreter of my own. Now
> > > I'm not likely to produce the next 'Ruby', but the recent announcement
> > > of Fu's 'TAO', and other languages, make me wonder if I could write
> > > something similar. Just for me, so to speak. A bit of fun.
> > >
> > > I did look at the possibility of going down the traditional route of
> > > [F]Lex/Yacc[Bison] and 'C', but it would be nice to write it in Ruby.
> > > Alright, it would be one interpreted language interpreting another,
> > > but as I said, 'a bit of fun'. That's if two small children and a
> > > scary wife allow me the time of course!!
> > >
> > > I see there are ruby-lex and ruby-yacc modules on RAA - anybody used
> > > these in anger and are they complete/good-enough?
> > >
> > > Has anybody done this kind of thing before? Not being a) a genius, b)
> > > Matz, or c) the owner of a fine beard, can anybody recommend any good
> > > URL's/tutorials/perhaps even books?
> > >
> > > I could grow a beard of course...
> >
> > The beard might help - but OTOH how will your scary wife react to that?
> > Might turn the whole thing into a mission impossible...
> > ;-)
> >
> > I haven't done this myself just a silly idea: when you compile your
> > language X right into Ruby code, then X might not be that slow during
> > execution because you save yourself one level of interpretation.
> >
> Or even better, do like GCC and have switchable 'back-ends' that
> generate for different execution environments ( ruby, python, perl,
> java ) etc. :-)
>
> > Kind regards
> >
> > robert
> >
> >
>
> --
> Into RFID? www.rfidnewsupdate.com Simple, fast, news.
>
>


--

All the best
Glenn
Aylesbury, UK



Lyndon Samson

5/2/2005 10:29:00 AM

0

He'd slay us for top-posting :-)

On 5/2/05, Glenn Smith <glenn.ruby@gmail.com> wrote:
> Sounds like I need to craft a "Richard Stallman" style beard then!!
>
>
> On 5/2/05, Lyndon Samson <lyndon.samson@gmail.com> wrote:
> > On 5/2/05, Robert Klemme <bob.news@gmx.net> wrote:
> > >
> > > "Glenn Smith" <glenn.ruby@gmail.com> schrieb im Newsbeitrag
> > > news:e09ac119050501122011ecce08@mail.gmail.com...
> > > > Always something I've wanted to write - an interpreter of my own. Now
> > > > I'm not likely to produce the next 'Ruby', but the recent announcement
> > > > of Fu's 'TAO', and other languages, make me wonder if I could write
> > > > something similar. Just for me, so to speak. A bit of fun.
> > > >
> > > > I did look at the possibility of going down the traditional route of
> > > > [F]Lex/Yacc[Bison] and 'C', but it would be nice to write it in Ruby.
> > > > Alright, it would be one interpreted language interpreting another,
> > > > but as I said, 'a bit of fun'. That's if two small children and a
> > > > scary wife allow me the time of course!!
> > > >
> > > > I see there are ruby-lex and ruby-yacc modules on RAA - anybody used
> > > > these in anger and are they complete/good-enough?
> > > >
> > > > Has anybody done this kind of thing before? Not being a) a genius, b)
> > > > Matz, or c) the owner of a fine beard, can anybody recommend any good
> > > > URL's/tutorials/perhaps even books?
> > > >
> > > > I could grow a beard of course...
> > >
> > > The beard might help - but OTOH how will your scary wife react to that?
> > > Might turn the whole thing into a mission impossible...
> > > ;-)
> > >
> > > I haven't done this myself just a silly idea: when you compile your
> > > language X right into Ruby code, then X might not be that slow during
> > > execution because you save yourself one level of interpretation.
> > >
> > Or even better, do like GCC and have switchable 'back-ends' that
> > generate for different execution environments ( ruby, python, perl,
> > java ) etc. :-)
> >
> > > Kind regards
> > >
> > > robert
> > >
> > >
> >
> > --
> > Into RFID? www.rfidnewsupdate.com Simple, fast, news.
> >
> >
>
> --
>
> All the best
> Glenn
> Aylesbury, UK
>
>


--
Into RFID? www.rfidnewsupdate.com Simple, fast, news.



Christian Neukirchen

5/2/2005 12:28:00 PM

0

Lyndon Samson <lyndon.samson@gmail.com> writes:

> On 5/2/05, Glenn Smith <glenn.ruby@gmail.com> wrote:
>> Sounds like I need to craft a "Richard Stallman" style beard then!!
>
> He'd slay us for top-posting :-)

Well, Emacs with gnus can deuglify "Outlook" posts, which also inverts
top-quotes. :-)

(Yes, I know that rms uses RMAIL.)

--
Christian Neukirchen <chneukirchen@gmail.com> http://chneuk...


Richard Cole

5/3/2005 6:47:00 AM

0

Glenn Smith wrote:

>Always something I've wanted to write - an interpreter of my own. Now
>I'm not likely to produce the next 'Ruby', but the recent announcement
>of Fu's 'TAO', and other languages, make me wonder if I could write
>something similar. Just for me, so to speak. A bit of fun.
>
>I did look at the possibility of going down the traditional route of
>[F]Lex/Yacc[Bison] and 'C', but it would be nice to write it in Ruby.
>Alright, it would be one interpreted language interpreting another,
>but as I said, 'a bit of fun'. That's if two small children and a
>scary wife allow me the time of course!!
>
>I see there are ruby-lex and ruby-yacc modules on RAA - anybody used
>these in anger and are they complete/good-enough?
>
>Has anybody done this kind of thing before? Not being a) a genius, b)
>Matz, or c) the owner of a fine beard, can anybody recommend any good
>URL's/tutorials/perhaps even books?
>
>I could grow a beard of course...
>
>
I played a bit with RACC but found the documentation a little terse so I
wrote a quick description you may find of some small help.

http://kvo.itee.uq.edu.au/twiki/bin/view/Mai...

I think you'll find writing parsers in a YACC like system (e.g. RACC) a
lot of fun. RACC is much easier to use to YACC/BISON.

regards,

Richard.