MGrammar Quick Challenge 2 - Unordered and optional multi-projections

by Justin Chase 26. June 2009 03:43

Given this grammar:

module test
{
    language test
    {
        syntax Main = OneTwo*;
        
        syntax OneTwo
            =  o:One t:Two "\r\n"
            => Result { One => true, Two => true }
            |  Two One "\r\n"
            => Result { One => true, Two => true }
            |  One "\r\n"
            => Result { One => true, Two => false }
            |  Two "\r\n"
            => Result { One => false, Two => true };
                
        token One = "one";
        token Two = "two";
        
        interleave Ignore = " ";
    }
}

How could I refactor the syntax "OneTwo" to have only a single projection?

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

MGrammar | MetaSharp | DSL | Oslo

Comments

Add comment


 

  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

Justin Chase

sweetest hat ever

I am a software developer from St. Paul MN and I work for Microsoft on the Expression team. This blog is about various technical topics I find myself encountering here and there. In addition to loving WPF and Xaml and Expression studio in general I have a special interest in DSLs, programming languages and games.

RecentComments

Comment RSS

Calendar

<<  March 2010  >>
MoTuWeThFrSaSu
22232425262728
1234567
891011121314
15161718192021
22232425262728
2930311234

View posts in large calendar