Creating a simple Textual DSL with Oslo, “M” Language, MGrammar and Intellipad


I wrote a post about Oslo and “M” Language and how you can use it to model data. But in that case, we were not using our own custom Textual DSL, we were using just “M” Language. You can see that post here:

Starting using OSLO, “M” Language, Oslo Repository and Intellipad

What I’m going to create now, is a Custom Textual DSL sample (DSL == Domain Specific Language), based on Oslo. It is going to be very, very simple. I just want to show the essence of “M” Language and MGrammar and how we can use Intellipad for that.

Intellipad is a text editor that comes with OSLO SDK, but as you can suppose (because of its name) it is kind of “intelligent”, I mean, it is Oslo Textual DSL oriented. 😉

I’m using OSLO SDK January CTP (Kind of a OSLO’s Pre-Beta). You can download it from this URL:

Microsoft “Oslo” SDK – January 2009 CTP (Refresh)

Basically, Intellipad gives you support for creating custom DSLs using the MGrammar language.

1.- Starting Intellipad with MGrammar support

Launch Intellipad with sample plug-ins loaded (from the start menu, Oslo SDK,  Icon called “Intellipad (Samples Enabled)”)or pass it a startup configuration file that includes the samples directory (startup config files are specified using the /c option). An example would be: ipad.exe /c: ipad-vs-samples.xaml

In the future, the MGrammar Language support will not require loading with samples. This is just because of this beta.

So now, change Intellipad mode to “M-Grammar”, like the following:


2.- Input file and our model’s text data

So, instead of starting writing M-Grammar like crazy (you should know its syntax, first), we’re going to start writing our model’s data, I mean, the simplified and even natural text I would like to provide as the origin.

Because of that, create an empty file (like a .TXT file) called “My DSL Input Data.input”, for instance. Put it in any folder you like.

Therefore, we need the pane to start writing in that ‘input file’. You get that pane/window when selecting “MGrammar Mode” menu and then select “Tree Preview”, like in the following screen:


Then, you’ll get a dialog asking for you input file, like this one:


Then, go and select that empty ‘My DSL Input Data’ file.

You’ll see Intellipad in the following form:


Cool!, so let’s start writing something we’d like to be consumed by our TEXTUAL DSL. For instance, the following text:

“Office 2007” by “Microsoft” is “nice”

“Windows 7” by “Microsoft” is “great”

“Visual Studio 2010” by “Microsoft” is “great”

Very simple, so, regarding that text, there are several products, company-names and adjectives, and, in this case, just the terms “by” and “is” are actually my language terms. You’ll see it like this:


So far, very simple. Now, I’m going to write my DSL program based on M-Grammar. You can copy & paste it on the MGrammar Mode pane:

module DemosOslo


language MyCatalogLanguage


syntax Main = a:Product+ => SoftwareCatalog { valuesof(a) };

syntax Product = productName:Name “by” company:Name “is” rating:Name

=> {ProductName = productName, CompanyName = company, Rating = rating};

token Name = ‘”‘ n:(any – ‘”‘)+ ‘”‘ => n;

interleave IgnoreMe = ” ” | “\n” | “\r”;



Then, you can see how MGrammar transforms the input text to the final form:


This is the generated data, in case you cannot read it on the copied screen:

      “Office 2007”
      “Windows 7”

Likewise, “M” Language works internally in a similar way, but it uses the M-Grammar program called (you can find it in the SDK, check it), instead the simple one we’re using here (I called it

Another great example is the new “MUrl” textual DSL, which is a M-based textual DSL and RunTime to build RESTFul Services clients (just the client) in a very simple way. I might write another post about MUrl, because it rocks! 🙂

There’s gonna be another textual DSL to actually build RESTFul services. It is called “MService”, but it is not still released. Douglas Purdy showed it a few weeks ago in MIX09, in Las Vegas. It really looks quite nice, as well.

Just want to highlight that Oslo, “M” Language and Quadrant are tools to create any kind of DSL Tools. Oslo is a “Modeling platform for ALL”. We’re not just talking about data or web-services, we’ll be talking about modeling ANYTHING!. 🙂

Comments (3)

  1. “MUrl” is a textual DSL and runtime for interacting with REST/HTTP services. It is actually just a great

  2. “MUrl” is a textual DSL and runtime for interacting with REST/HTTP services. It is actually just a great

  3. “MUrl” is a textual DSL and runtime for interacting with REST/HTTP services. It is actually just a great

Skip to main content