Search code examples
modelingxtexteclipse-sirius

Space error in sirius


I created my xtext grammar, and now I use sirius to model, the problem I have is when I create an element from the palette (eg I create a button), In the file that takes the extension of the xtext in my case 'instance.pfe' I find a space error, the space given by modeling is not the same in the grammar . I did not understand where this error came from , And how to solve it, thank you for helping me.

this is an example this is an example

My grammar


Solution

  • you should not make use of spaces inside keywords. this will have all kinds of wired sideeffects like the one you are facing.

    so insteadof using

    SomeRule: 'somekeyword : ' somevalue=INT
    

    you should use

    SomeRule: 'somekeyword' ':'  somevalue=INT
    

    if you really want to enforce a space then introduce a terminal for it

    terminal SPACE: ' ';
    
    SomeRule: 'somekeyword' SPACE ':' SPACEsomevalue=INT
    

    Update:to enable class splitting

            parserGenerator = {
                options = {
                    classSplitting = true
                }
            }