van Godard wrote:
The canonical way to incorporate typing (including much richer type systems than this) in a formal grammar is through van Wijngaarden grammars. See http://en.wikipedia.org/wiki/Algol68. It is possible to generate both the parser and type analysis from such a grammar, and compilers that do so still exist.
Sadly, there is no Boost VWG library. Perhaps you'll write one?
I hadn't even considered the notion of a type system for a DSEL, but it makes perfect sense. Unfortunately, the only tutorial I found for van Wijngaarden grammars is here: http://homepages.cwi.nl/~steven/vw.html Perhaps it's because I'm tired, but I'm not making heads or tails of it at the moment. Can you point me to a gentler introduction? (Way back when I started with expression templates, I thought that calling them an "embedded language" was just a cute metaphor, but much can be gained from taking the serious view that these really *are* languages, deserving of grammars, semantic actions, ... type systems, too. Once we fully embrace that view, there's decades worth of programming language theory we can leverage.) -- Eric Niebler BoostPro Computing http://www.boostpro.com