Oslo highlight: MGrammar

While Oslo may bring us graphical, model and data driven development to the Microsoft Development Platform, the tools and underlying technologies offer interesting textual capabilities. For me, MGrammar actually seems to be the highlight in the Oslo toolset.

MGrammar is basically a GLR parser generator, that can be used from within the .NET framework right now by downloading the Oslo SDK. Microsoft stresses that MGrammar and the M toolset was not planned at all to be included in Oslo. Though, it seems to span a whole new set of opportunities for .NET developers.

Highlights of MGrammar, which I have not seen in other parser generators so far:

  • Creates a generalized LR parser, basically an LR parser, that is capable to resolve ambiguities.
  • Parameterized syntax rules.
  • Inline transformation into a labeled directed graph.
  • Sophisticated error recovery in the parser.
  • Token and syntax annotations used for highlighting inside editors. This is already supported in Intellipad, the primary tool for editing MGrammar source files.
  • Directly embeddable parser for .NET.
  • .NET accessible AST output (in the form of the labeled directed graph).
  • Planned support for Intellisense in VS and Intellipad
  • (Yet unsupported) base grammar library for parsing Integers, Strings, ... .
  • Syntax definitions can be composed, i.e. reused and included in other grammars.
  • The specification of the MGrammar input language will be an open standard.

I am planning to use MGrammar to solve a number of problems for which I would have previously used internal C# DSLs.

For developers this seems to be the way to boil things down to the essence how syntax structured content is specified. Let’s see how well it goes.

For a one hour introduction, take a look at the MGrammar talk at the PDC 2008.

build DSLs now, no excuses anymore!

yours
armin