From: ptkwt@... (Phil Tomson) Date: 2005-02-16T18:34:51+09:00 Subject: Re: Ruby as a domain specific language? In article <1108491215.889243.288190@o13g2000cwo.googlegroups.com>, wrote: >Hi > >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? > >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. > >Thanks in advance for your help, >Calum > I would tend to say it more like: Ruby for creating a domain specific language (DSL). Ruby excells in creating DSLs primarily because of it's code blocks. I've created a couple of DSLs with Ruby: QDL (Quantum Description Language) - a language for describing quantum logic circuits. See: http://nexp.cs.pdx.edu/~qc/cgi-bin/view/QC/QuantumDesignLanguage RHDL (Ruby Hardware Description Langauge) - a language for describing hardware (and simulating concurrency). See: http://www.aracnet.com/~ptkwt/ruby_stuff/RHDL/ Code blocks allow you to create a very natural-looking DSL directly in Ruby without need of a special parser. There's also Rake which could definately fall into the catagory of a DSL. Phil