MSDN > Home page del forum > Microsoft SQL Server Modeling > Changing default values in MGrammar
Formula una domandaFormula una domanda
 

Con rispostaChanging default values in MGrammar

  • giovedì 25 giugno 2009 20.38justncase80 Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     
    I have a syntax something like this:

    syntax Foo 
         =   b:Bar z:Baz?
         => Foo { Bar => b, Baz => z }

    But if Baz doesn't match then the graph projects to be:

    Foo { Bar => Bar { ... }, Baz => null }

    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.



    Here is a more complete example

    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
      }
    ]

    • Modificatojustncase80 giovedì 25 giugno 2009 20.38formatting
    •  

Risposte

Tutte le risposte