[R] Writing 'domain specific languages' with R

Duncan Murdoch murdoch.duncan at gmail.com
Thu Jun 21 14:09:15 CEST 2012


On 12-06-21 7:20 AM, Roberto Brunelli wrote:
> I would like to port to R the IPAT-S language, kind of a 'domain
> specific' scripting language for developing quantitative models for
> medium and long-term sustainability scenarios (www.ipat-s.org).
>
> I think that in order to replicate its syntax I need some kind of
> 'macro' functionality to reparse it into R constructs. Are there any
> examples of tweaking R to support a domain specific input syntax?
>
> Thanks a lot,
>

There are two approaches:  invent a new interpretation for R syntax, and 
just use the regular parse() function together with a new way of 
evaluating it (the approach used in model formulas), or write a full 
fledged parser for your language.  The latter is used by 
tools::parse_Rd.  It sounds as though you want the second approach.

I don't know of any examples of full parsers written in R. Most of 
parse_Rd is written in Bison and C code.

Duncan Murdoch



More information about the R-help mailing list