Microsoft Developer Network > 포럼 홈 > Microsoft SQL Server Modeling > MGrammar - Unordered and optional multi-projections?
질문하기질문하기
 

답변됨MGrammar - Unordered and optional multi-projections?

  • 2009년 6월 26일 금요일 오후 3:40justncase80 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     코드 있음
    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? In my real language I have a bunch of other tokens before and after the two optional and unordered items and the | list can be quite extensive and long if I have to enumerate every possible combination. Furthermore if you have a third item ("OneTwoThree" for example) then your | list can get exponentially grow. 

    Is there a trick to defining unordered and optional items in the middle of a complex syntax?

답변

  • 2009년 6월 27일 토요일 오후 1:28lcorneliussen 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨
    Hi. Had the same issue last year. Gio promised to fix it :-)

    http://social.msdn.microsoft.com/Forums/en-US/oslo/thread/3d5cb0ce-ac57-47e0-a17c-55e977f2b56b

    Giovanni Della-Libera : "Hi!  I'm on the dev team for MGrammar and we've been thinking about this scenario, so I'm glad to see a customer hitting it.  We'd like to make this easy to indicate in the language.  Will let you know once we've made progress here."
    • 답변으로 표시됨justncase80 2009년 6월 27일 토요일 오후 3:52
    •  

모든 응답

  • 2009년 6월 27일 토요일 오후 1:28lcorneliussen 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨
    Hi. Had the same issue last year. Gio promised to fix it :-)

    http://social.msdn.microsoft.com/Forums/en-US/oslo/thread/3d5cb0ce-ac57-47e0-a17c-55e977f2b56b

    Giovanni Della-Libera : "Hi!  I'm on the dev team for MGrammar and we've been thinking about this scenario, so I'm glad to see a customer hitting it.  We'd like to make this easy to indicate in the language.  Will let you know once we've made progress here."
    • 답변으로 표시됨justncase80 2009년 6월 27일 토요일 오후 3:52
    •  
  • 2009년 6월 27일 토요일 오후 3:53justncase80 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    Yup that appears to be the exact same problem.