MGrammar Quick Challenge

by justin 25. June 2009 03:41

Given the input text "bar", modify this language:

module test
{
    language test
    {
        syntax Main = Foo;
        
        syntax Foo 
            =  b:Bar z:Baz?
            => Foo { Bar => b, Baz => z };
        
        token Bar = "bar" => true;
        token Baz = "baz" => true;
    }
}

To produce the graph:

Main[
  Foo{
    Bar => true,
    Baz => false
  }
]

Tags: ,

MGrammar | Oslo

Comments

6/24/2009 3:15:43 AM #

Rocky Lhotka helped me solve this perfectly by pointing out the "empty" keyword.

b : (b : Bar => b | empty => false)
z : (b : Baz => b | empty => false)

Justin Chase |

Comments are closed

About Me

sweetest hat ever

I'm a software developer from Minnesota and this blog largely focuses on various technical concepts I am thinking about at the moment. I currently work for Microsoft in the St. Paul office of the Expression product group.

RecentPosts