Which parts of a Ruby DSL will I need to build by hand?
-
14-09-2019 - |
Question
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 :)
No correct solution
OTHER TIPS
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.
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.