Changing default values in MGrammarI have a syntax something like this: <div><br/></div> <div> <pre>syntax Foo = b:Bar z:Baz? =&gt; Foo { Bar =&gt; b, Baz =&gt; z }</pre> <div><br/></div> But if Baz doesn't match then the graph projects to be:</div> <div><br/></div> <div> <pre>Foo { Bar =&gt; Bar { ... }, Baz =&gt; null }</pre> <div><br/></div> What I'd really like is for Baz to not project to null but something else instead (such as Baz { }). The only way I could get it to work so far is to completely duplicate the syntax one with Baz required and one with Baz totally missing and change the greater projection.</div> <div><br/></div> <div><br/></div> <div><br/></div> <div><strong>Here is a more complete example</strong></div> <div><br/></div> <div>Given the input text &quot;bar&quot;, modify this language:</div> <div><br/></div> <div> <pre>module test { language test { syntax Main = Foo; syntax Foo = b:Bar z:Baz? =&gt; Foo { Bar =&gt; b, Baz =&gt; z }; token Bar = &quot;bar&quot; =&gt; true; token Baz = &quot;baz&quot; =&gt; true; } }</pre> </div> <div><br/></div> <div>To produce the graph:</div> <div><br/></div> <div> <pre>Main[ Foo{ Bar =&gt; true, Baz =&gt; false } ]</pre> <br/></div>© 2009 Microsoft Corporation. All rights reserved.Thu, 25 Jun 2009 22:04:11 Z82e528a9-d484-414f-806d-b3ce8f1cdfb1http://social.msdn.microsoft.com/Forums/en-US/oslo/thread/82e528a9-d484-414f-806d-b3ce8f1cdfb1#82e528a9-d484-414f-806d-b3ce8f1cdfb1http://social.msdn.microsoft.com/Forums/en-US/oslo/thread/82e528a9-d484-414f-806d-b3ce8f1cdfb1#82e528a9-d484-414f-806d-b3ce8f1cdfb1justncase80http://social.msdn.microsoft.com/Profile/en-US/?user=justncase80Changing default values in MGrammarI have a syntax something like this: <div><br/></div> <div> <pre>syntax Foo = b:Bar z:Baz? =&gt; Foo { Bar =&gt; b, Baz =&gt; z }</pre> <div><br/></div> But if Baz doesn't match then the graph projects to be:</div> <div><br/></div> <div> <pre>Foo { Bar =&gt; Bar { ... }, Baz =&gt; null }</pre> <div><br/></div> What I'd really like is for Baz to not project to null but something else instead (such as Baz { }). The only way I could get it to work so far is to completely duplicate the syntax one with Baz required and one with Baz totally missing and change the greater projection.</div> <div><br/></div> <div><br/></div> <div><br/></div> <div><strong>Here is a more complete example</strong></div> <div><br/></div> <div>Given the input text &quot;bar&quot;, modify this language:</div> <div><br/></div> <div> <pre>module test { language test { syntax Main = Foo; syntax Foo = b:Bar z:Baz? =&gt; Foo { Bar =&gt; b, Baz =&gt; z }; token Bar = &quot;bar&quot; =&gt; true; token Baz = &quot;baz&quot; =&gt; true; } }</pre> </div> <div><br/></div> <div>To produce the graph:</div> <div><br/></div> <div> <pre>Main[ Foo{ Bar =&gt; true, Baz =&gt; false } ]</pre> <br/></div>Thu, 25 Jun 2009 20:38:06 Z2009-06-25T20:38:58Zhttp://social.msdn.microsoft.com/Forums/en-US/oslo/thread/82e528a9-d484-414f-806d-b3ce8f1cdfb1#00037268-1633-4c45-86a1-0c9185a4fd6ehttp://social.msdn.microsoft.com/Forums/en-US/oslo/thread/82e528a9-d484-414f-806d-b3ce8f1cdfb1#00037268-1633-4c45-86a1-0c9185a4fd6ejustncase80http://social.msdn.microsoft.com/Profile/en-US/?user=justncase80Changing default values in MGrammar<span style="font-size:12px;color:#444444">Rocky Lhotka helped me solve this perfectly by pointing out the &quot;empty&quot; keyword.<br/><br/>b : (b : Bar =&gt; b | empty =&gt; false)<br/>z : (b : Baz =&gt; b | empty =&gt; false)</span>Thu, 25 Jun 2009 22:04:04 Z2009-06-25T22:04:04Z