270 likes | 400 Views
TL31. Building Textual Dsls With The "Oslo" Modeling Language. Chris Anderson Engineer Microsoft Corporation. Giovanni Della-Libera Development Lead Microsoft Corporation. What Is Oslo?. “M” The modeling language . “Quadrant” The modeling tool. Repository
E N D
TL31 Building Textual Dsls With The "Oslo" Modeling Language Chris Anderson Engineer Microsoft Corporation Giovanni Della-Libera Development Lead Microsoft Corporation
What Is Oslo? “M” The modeling language “Quadrant” The modeling tool Repository The store for models
What Is "M"? A family of languages for manipulating data “MGrammar” Text to data “MGraph” Representing data “MSchema” Schematizing data
The "M" Language DSL DSLX DSLY Point.m Domain Model DomainX.m Domain Model DomainY.m Domain Model PointLanguage.mg Domain Grammar DomainX.mg Domain Grammar DomainY.mg Domain Grammar "M" Domain-specific data models • type Point { • X : Integer; • Y : Integer; • } MSchema Domain-specific grammars • language PointLanguage { • syntax Main = h:Integer "," v:Integer • => Point { X { h }, Y { v }};} MGrammar Abstract data model • Point { X { 100 }, Y { 200 } } MGraph
Let's Parse… Contact: giodl – 425-555-1212
Mgrammar As Seen In Intellipad Input Grammar Output Text MGraph Transform Errors
demo Defining A Language
Processing Contact: giodl – 425-555-1212 Step 1: Tokenize
Processing Contact: giodl – 425-555-1212 Tokens define the “words” of your language token Alias = ("A".."Z" | "a".."z")+;
Processing Contact: giodl – 425-555-1212 Step 2: Parse
Processing Contact: giodl – 425-555-1212 Syntax defines the “sentences” of your language syntax ContactEntry = "Contact" ":" alias:Alias "-" phone:Phone => Contact { Alias { alias } , Phone { phone } };
Processing Contact: giodl – 425-555-1212 Remember interleave? interleave Ignorable = " " | "\n" | "\r“;
Processing Contact: giodl – 425-555-1212 Shape the data… syntax ContactEntry = "Contact" ":" alias:Alias "-" phone:Phone => Contact { Alias { alias } , Phone { phone } };
Processing Contact: giodl – 425-555-1212 Contact Alias Phone giodl 425-555-1212 syntax ContactEntry = "Contact" ":" alias:Alias "-" phone:Phone => Contact { Alias { alias } , Phone { phone } };
Processing Contact Alias Phone giodl 425-555-1212 syntax ContactEntry = "Contact" ":" alias:Alias "-" phone:Phone => Contact { Alias { alias } , Phone { phone } };
demo Advanced Topics
Advanced MGrammar • Attributes • Case sensitivity @{CaseSensitive[false]} • valuesof() • Parameterized Rules syntax CommaList(Element) = ...;
demo Using "MGrammar"
Consuming MGrammar From CMD • MG.exe • MGrammar Image file (MGX) • MGX.exe • MGX + input file output file (MGraph, XML, etc.)
Consuming MGrammar From CLR • MG Build task • MGrammar Image file (MGX) • MGrammarCompiler • In memory version of MG Build task • DynamicParser • MGX + input stream MGraph in memory • IGraphBuilder • MGraph “reader” and “builder”
demo Something More Real…
WIX Sample Language • Simple VB-esque language • ~50 lines of MGrammar • “Compiler” that generates WIX XML format • ~400 lines of C# • Walks the MGraph using IGraphBuilder • Uses a basic WIX object model in memory to generate XML • Standard WIX tool chain to generate MSI
Summary • MGrammar • Language for creating textual DSLs • Specification will be released under OSP • Download the CTP Today! • http://msdn.microsoft.com/oslo • Build your own language! Please Send Feedback chrisan@microsoft.com | giodl@microsoft.com
Q&A Please use the microphones provided
Evals & Recordings Please fill out your evaluation for this session at: This session will be available as a recording at: www.microsoftpdc.com
© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.