How to maka a rule LL(*) while preserving semantics? [message #1767318] |
Tue, 04 July 2017 11:49  |
Eclipse User |
|
|
|
Hi,
whenever I have a rule like this:
XText asks me for applying left-refactoring. On paper, I'd do it like this:
A -> cC | "a"
C -> A | AB
(...)
But in XText you don't have "null" rules, I believe. So I do it by mixing in regular expressions:
And XText seems to swallow it as a "left refactorization".
The problem is that in my parsed model I want cA and cAB to mean different things and to be mapped into different ECore classes, and as I understand, my "regular expression" impedes that.
Let's show it on a real XText snippet. How can I make the following rule LL(*) and at the same time get different and meaningful ECore classes for alternatives 2 and 3?
terminal TYPE:
ID |
('(' TYPE ')') |
('(' TYPE ')' 'throws')
;
I've tried this hoping that it would guide XText throughout choices, but it did not work:
terminal TYPE:
ID |
COMPLICATED_TYPE
;
terminal fragment COMPLICATED_TYPE:
('(' TYPE ')') |
COMPLICATED_TYPE_WITH_THROWS
;
terminal fragment COMPLICATED_TYPE_WITH_THROWS:
('(' TYPE ')' 'throws')
;
Cheers, David.
[Updated on: Tue, 04 July 2017 11:50] by Moderator
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04466 seconds