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

G

Glenn Smith

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...
 
B

Bill Guindon

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/pagetemplate/
* http://coolnamehere.com/products/pagetemplate/
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 :)
 
G

Glenn Smith

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!!
 
C

Charles Comstock

Glenn said:
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
 
R

Robert Klemme

Glenn Smith said:
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
 
G

Glenn Smith

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


Glenn Smith said:
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
 
L

Lyndon Samson

He'd slay us for top-posting :)

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


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

--

All the best
Glenn
Aylesbury, UK
 
R

Richard Cole

Glenn said:
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/Main/RjBlog41

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.
 
G

Glenn Smith

Excellent Richard, thanks!!

Glenn said:
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/Main/RjBlog41

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.
 

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,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top