views:

203

answers:

2

If I want to build a DSL in Ruby 1.9 or JRuby, will I need to do any of these stages by hand:

  • Lexing
  • Interpretation
  • Parsing
  • Just-in-time compilation

Obviously, being a programmer, I don't like to write actual code as much as I can get away with, so I'm hoping none of these steps require manual labor :)

+4  A: 

It's all done using metaprogramming. You don't have to do any of the things you list. Jamis Buck has a nice blog post on Writing Domain Specific Languages using Ruby.

John Topley
+3  A: 

It depends on what you want. For writing an internal(read: uses ruby syntax) DSL, it is just ruby all the way down. If you want to build a DSL that doesn't use ruby syntax you could look at the treetop gem.

Jeremy Mcanally has a pretty good presentation about DSLs. He goes through both external and internal DSL stuff.

BaroqueBobcat