|
|
Re: [Xtext 2.4.3] What to do if 'keyword' can occur as an ID as well? [message #1219333 is a reply to message #1219330] |
Tue, 03 December 2013 11:43 |
Wayne Campbell Messages: 11 Registered: June 2013 |
Junior Member |
|
|
Quote:
Because the "Entity" denotes that you are inside the AFile rules which do not recognise a "TOP" keyword.
So IIRC there is no conflict at all.
Hm, that's what I thought at first, too. But if I open file A with my Runtime Eclipse, then all occurences of 'TOP' are recognized as a keyword, causing an error ("Mismatched input 'TOP', expecting RULE_ID").
My standalone test tool reports the same syntax error.
Quote:
In the standard XTEXT terminals, ther is a build-in escape for IDs implemented:
a "^" in front of the ID which separetes the ID from a keyword is removed automatically.
So entering name=^TOP will be turned into a simple TOP
Yes, I am aware of that. Unfortunately I cannot modify the source files. The whole file format is a lot more complex, so I really need to avoid messing around with file contents manually.
--- EDIT ---
I changed the 'TOP' rule to 'TOP ', and that did the job, as there must be a whitespace anyway.
This works for now, and it does not smell as badly as manually crawling the input files. But if anybody has a even better solution I would be very happy
--- /EDIT ---
[Updated on: Tue, 03 December 2013 12:05] Report message to a moderator
|
|
|
|
Re: [Xtext 2.4.3] What to do if 'keyword' can occur as an ID as well? [message #1219353 is a reply to message #1219333] |
Tue, 03 December 2013 13:48 |
Sven Efftinge Messages: 1823 Registered: July 2009 |
Senior Member |
|
|
Hi Wayne,
for that you should declare a non-terminal rule like this:
MyIdWithKeywords :
ID | 'keyword1' | 'keyword2';
And then use that rule at the appropriate places.
Sven
Am 12/3/13 12:43 PM, schrieb Wayne Campbell:
> Quote:
>> Because the "Entity" denotes that you are inside the AFile rules which
>> do not recognise a "TOP" keyword.
>> So IIRC there is no conflict at all.
>
> Hm, that's what I thought at first, too. But if I open file A with my
> Runtime Eclipse, then all occurences of 'TOP' are recognized as a
> keyword, causing an error ("Mismatched input 'TOP', expecting RULE_ID").
> My standalone test tool reports the same syntax error.
>
>
> In the standard XTEXT terminals, ther is a build-in escape for IDs
> implemented:
> a "^" in front of the ID which separetes the ID from a keyword is
> removed automatically.
> So entering name=^TOP will be turned into a simple TOP
>
> Yes, I am aware of that. Unfortunately I cannot modify the source files.
> The whole file format is a lot more complex, so I really need to avoid
> messing around with file contents manually.
--
Need professional support for Xtext or other Eclipse Modeling technologies?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : http://blog.efftinge.de
|
|
|
|
|
|
Re: [Xtext 2.4.3] What to do if 'keyword' can occur as an ID as well? [message #1219531 is a reply to message #1219518] |
Wed, 04 December 2013 12:29 |
Uli Merkel Messages: 250 Registered: June 2013 |
Senior Member |
|
|
Hi Ed,
thanks for pointing out a context where this will cause trouble.
I had not encountered this situation in the legacy areas I inspected,
just a simple KEYWORD myname KEYWORD1= abc, def, xyz
where the second keyword is "KEYWORD1="
So as long as a situation like the one you mentioned can be excluded,
it seems to be an acceptable way to specify the first KEYWORD as "KEYWORD ".
This way, an existing DSL will still be useable if it reads:
KEYWORD KEYWORD KEYWORD1= KEYWORD, KEYWORD1
[Updated on: Wed, 04 December 2013 15:21] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03952 seconds