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.
Asked
Active
Viewed 66 times
0
-
How does the grammar look like? Did you implement the formatter? – Christian Dietrich Apr 12 '17 at 19:54
-
No I have not implemented the formatter .. Maybe that's the mistake , I saw on the internet that I have to activate it !! But i have no idea about its implementation ?? – Senoussaoui Ikram Apr 13 '17 at 19:14
-
No but depending on you grammar and the way you edit the model the formatter and or parser may do wired things or have a bug. This is why I was asking for a small reproducible grammar – Christian Dietrich Apr 14 '17 at 06:22
-
I modified my question by inserting my grammar.. – Senoussaoui Ikram Apr 14 '17 at 14:01
-
The link to your grammar doesn't work for me. I can't access without having a Google account. – Thomas Fritsch Apr 14 '17 at 16:39
1 Answers
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
-
-
-
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