From: debbie@... Date: 2005-09-10T09:11:30+09:00 Subject: Using Ruby as a preprocessor for another language I have the misfortune of being stuck programming in a very bad scripting language that has poor support for functions, variable substitutions, loops, etc. etc. (It's a proprietary language called Aegis scripting language, for scripting NPCs in a game.) I've been using Ruby as a macro pre-processor so that I can write more maintainable scripts without violating the DRY (Don't Repeat Yourself) principle. Presently, I have the following functionality: 1. #{...} strings are evaluated by Ruby 2. lines starting with @ are evaluated by Ruby Thanks to Ruby's power and simplicity, the ENTIRE pre-processor is just these few lines: while line = gets line.chomp! if line =~ /^\s*\@(.*)$/ # Line starts with a @; it is Ruby code puts $1 else # Line should be printed, with #{} substitution available puts "puts \"#{line.gsub('"', '\"')}\"" end end This allows me to "compile" a template like this: http://theanimaro.com/debbie/ruby/template.sc into a script like this: http://theanimaro.com/debbie/ruby/test.sc Now my question is, am I reinventing the wheel here in that pre-processor code I wrote---is there already an existing module in the RAA that does this? I didn't want to use ERuby because I find that those <% %> <%= %> tags everywhere make the script unreadable (ERuby is more for HTML IMO).