Infosys Microsoft Alliance and Solutions blog

« Blend 3 and SL 3 Preview available | Main | "Oslo" SDK January 2009 CTP (Refresh)! »

Oslo MGrammar : @{CaseSensitive[false]} or @{CaseInsensitive}?

I wrote a small MGrammar for creating my own DSL and all I wanted to do was to make my DSL a Case Insensitive one. I thought this would be an easy task with the CaseSensitive attribute that I found in the MGrammar Language Specification Document that gets installed when you install the Oslo SDK. But when I used the attribute in my grammar, it just didn't work! Being a nascent technology, I couldn’t find much help on the web, but when I went through the Release Notes of the Oslo SDK Jan 2009 CTP, I could find a section for breaking changes, where I could find the fix for this problem. In fact MS has renamed the attribute to CaseInsensitive. It was just that the MGrammar Language Specification document had not been updated (don't know how could they miss this!) to reflect the same. CaseSensitive attribute was part of the earlier MGrammar specification.

So now if you want to make your DSL case insensitive you can decorate your language with the @{CaseInsensitive} attribute as shown below:

module HelloWorld {
    @{CaseInsensitive}
    language HelloWorldLanguage {
        syntax Main
          = Hello World;
        token Hello
          = "Hello";
        token World
          = "World";
        interleave Whitespace
          = " ";
    }
}

The above language doesn't just recognize "Hello World", but also recognizes "hELLO WoRLD", "HELLO world", "HeLLo wORlD" etc.

TrackBack

TrackBack URL for this entry:
http://www.infosysblogs.com/microsoft-mt/mt-tb.fcgi/359

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

Please key in the two words you see in the box to validate your identity as an authentic user and reduce spam.

Subscribe to this blog's feed

Infosys on Twitter