0

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

Senoussaoui Ikram
  • 197
  • 1
  • 1
  • 9

1 Answers1

0

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
            }
        }
Christian Dietrich
  • 11,778
  • 4
  • 24
  • 32
  • Yes I used the notation 'SomeRule: 'somekeyword' ':' somevalue=INT' before changing it to the current one but I always had the same problem when I slide a button for example, in the text file of the model I find an error, it inserts a space that it Is not found in the grammar for more detail: 'text' ':' text1=textType ';' Sirius inserts a space between 'text' and ':' ...... in other cases it removes this space.... I do not understand why ?? – Senoussaoui Ikram Apr 15 '17 at 12:49
  • Yes but if you do your grammar right it will work with and without space – Christian Dietrich Apr 15 '17 at 12:50
  • => why is there an error with the space is the thing to be looked at – Christian Dietrich Apr 15 '17 at 12:52
  • Ok so I will rewrite my grammar with a fixed syntax and I will see if the error disappears ......thank you very much Sir. – Senoussaoui Ikram Apr 15 '17 at 15:05
  • I changed my grammar and fixed a syntax but now I have an error when i generate Xtext Artifacts as follows: The code for the static initializer is exceeding the 65535 bytes limit. – Senoussaoui Ikram Apr 19 '17 at 15:32
  • Have a look at class method splitting in the options in (possibly to be added ) parserGenerator={...} in the language section – Christian Dietrich Apr 19 '17 at 15:38
  • I understood that there is no space in the grammar file but I can't remove any rules I have to put them all ,is what there is a method, Can be split a part in an external file or another solution...... thank you for helping me – Senoussaoui Ikram Apr 19 '17 at 15:42
  • Ok I'll pick this class now – Senoussaoui Ikram Apr 19 '17 at 15:49
  • p.s.: which is the java class you get the error about? – Christian Dietrich Apr 19 '17 at 15:53
  • p.s: and make sure you really dont have any spaces in keywords. (there is a warning for that in xtext 2.11+) – Christian Dietrich Apr 19 '17 at 16:04
  • I changed the file that takes the extension (.mwe2) I replaced the following line: 'fragment = parser.antlr.XtextAntlrUiGeneratorFragment' by: fragment = parser.antlr.XtextAntlrUiGeneratorFragment auto-inject { Options = { // backtrack = true ClassSplitting = true MethodsPerClass = "100" FieldsPerClass = "100" } } And the problem is solved, and now I will test it in sirius if there is always the space problem or not. – Senoussaoui Ikram Apr 19 '17 at 16:16