Today, when developers want to create a new way to describe a domain, such as all of the attributes of a contact,...
By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.
they use XML, which forces the developer to tolerate a lot of angle brackets. Developers are willing to live with it, because creating a new parser is fairly challenging. The new MGrammar (Mg) from Microsoft promises a new alternative for developers.
As Microsoft was working on the new Oslo modeling environment, they started toying around with a tool for automatically parsing text into a database. However, once customers began to hear about it, the excitement began to build, and Microsoft decided to roll this out as the Mg component of Oslo, which was made available at last fall's PDC.
Developers are finding that Mg is not just another parser. James Clark noted in his modeling blog that while he has always found parsers to be a pain, Mg works differently in that it is purely declarative. It does this by constructing a labeled tree that represents the result of the parse. It also works more dynamically than a typical parser.
Mg is a functional transformation language for turning text into data. It complements the other Oslo components MSchema for schematizing data, and MGraph for representing data.
With MGrammar you start with a language declaration. For example, if you were coming up with a domain specific language for specifying customers and orders, you would create a language declaration and specify the syntactic parts of those languages. Mg will generate a set of .Net source code that will produce a component that defines a lexicon to tokenize the input. Then the developer can use the tokens to format a higher level syntax. Each unit of syntax is called a production.
Paul Vick, who recently moved to the Mg team from the Visual Studio team at Microsoft said, moving to M Grammar may not be that big of a move. The grammar is designed to build languages, he said. In his words, it covers, not the whole end-to-end experience of a programming language, "but just the front end syntactical aspects."
To get started, developers need to download the Oslo CTP from the MSDN Website. It includes the Intellipad Text editor tool, although any text editor can be used to create Mg files. The document, "M Grammar in a Nutshell,"shows all of the steps needed to get up to speed on Mg. It includes language specifications that let you review the language constructs that are available.
MGrammar Presentation-PDC 2009
Modeling Language Team Blog- MSDN.com
"MGrammar in a Nutshell"-MSDN.com