maetl / calyx

A Ruby library for generating text with recursive template grammars.
MIT License
62 stars 5 forks source link

Tracery Support #19

Open tra38 opened 7 years ago

tra38 commented 7 years ago

Should Calyx support files written in Tracery? It seems that Tracery grammars are more common lately, and Calyx should probably support them to stay relevant (especially as one of the rationales for #7 is to eventually handle Tracery grammars). There did seem to be an abortive attempt at building a gem to handle Tracery so this might be a rather ambitious project. There's also the possibility that the Tracery grammar may be so complex that it might be better to treat it as its own separate library (and to treat Calyx as a dependency of that library).

maetl commented 7 years ago

I would be interested in this. Interoperability between tools is a good goal to aim for.

I’ve already experimented with parsing the old style of Tracery grammars in Calyx and it works fine—it can be done with simple string rewriting operations. The problems here are related to native JavaScript string functions being called—for it to work as a general library, we’d need to introduce a compatibility layer that maps JavaScript to Ruby (eg: rule.toUpperCase => rule.upcase).

Also, the next version of Tracery looks like it will have a bunch of new syntax and conventions to handle. I haven’t looked into it yet, but just going by the progress @galaxykate is posting online, it looks like a greatly expanded range of features.