cnmaclean / hotmail.com wrote: > In my company, we're looking at creating a domain-specific language. > Instead of being a totally proprietary language, which we'd have to > support and which would probably be limited in various ways etc., I was > thinking about the possibility of basing it on an existing language, > and Ruby in particular seemed to come to my attention. > I haven't really used Ruby at all, but from what I've read, it seems > like it could be quite suitable. > > What I'm wondering is, are there any good resources on using Ruby as a > domain-specific language? Is there any documentation on the different > way in which Ruby can be extended to support domain-specific > constructs? There was once a post by Phil Tomson about a Quantum Design Language which might be close to what you're after: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/99734 > What we're trying to do in particular is define a data description > langauge, where we can define human-readable "translations" for hex > data. This would be largely in a declarative style (e.g. "DataItem > Name='My Data' Coding='Language' Length=2"); using something like Ruby > might allow us to do the simple things (like the above) simply, but > still keep open the possibility of using the power of a programming > language where required - e.g. where the data structure is particularly > dynamic. > The other characteristic of our language is that it will probably be > fairly hierarchically structured. For example, we have the concept of > translations for files, which may be contained in folders. So we'd > want to specify parent folders (with identifiers), and other > files/folders as children of these folders; the "leaf" files would have > translations etc. associated with them. The other option is to go with yaml for the data file and process it with Ruby. It might not be the best thing for human editing (as it's whitespace significant) but it should be very easy to define hierarchical constructs to be later processed by Ruby. HTH, Assaph