Torkel Ödegaard has done a very nice, detailed look at created a DSL in MGrammar for the WatiN browser automation library, including a look at the code he used to parse the Abstract Symbol Tree produced by MGrammar to do something useful.
On the Oslo team, we think of three kinds of models:
Drawings: This is modeling to communicate from human to human, e.g. on a white board or in Visio. An architecture diagram in a design document is an example of such a thing.
Model-Assisted: This is modeling where we’re talking to a computer, most often to generate code, e.g. the .edmx file used by Visual Studio to generate C# data access code.
Model-Driven: Here we’re also communicating from a human to a computer, but instead of doing it at development-time to generate code, the model is actually used at run-time to drive a run-time, e.g. a Workflow definition to drive the Workflow engine.
The M family of languages is meant for all kinds of things, from executable models, e.g. defining a workflow and executing it via the Workflow runtime, to allowing a business person to express something in a language, either visual or textual, that they understand so that it can be communicated as formally as desired to another human. As an example of the latter, Claudio Perrone has implemented a DSL in MGrammar for Behavior-Driven Development.
It is amazing to me how many of these little DSLs have popped in M just since the PDC. Keep ’em coming!
I’m thinking it’s time for another DevCon. I know it’s been a while since the last one (in fact, I hear there was some kind of petition to have another one? : ), so we’re long past due.
This one will be on all things data-driven, model-based and/or DSL enhanced. I’m thinking March or April of 2009. Who’s interested?
Justin Bailey has built a little language in MGrammer to create tasks and even better, he’s provided a very tutorial on how he did it. Following along with him would make a great way to learn the basics of Mg. Plus, I love his conclusions:
“Mg is clearly a powerful technology for defining languages. The above is a trivial use, but already we have bypassed most simple file parsing techniques. Quoted strings and balanced parentheses are the bane of non-parsing techniques and it appears that Mg will be placing those abilities within reach of most .NET developers.”