Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Syntax highlight for Enums
Syntax highlight for Enums [message #691296] Fri, 01 July 2011 07:28 Go to next message
Balazs Varnai is currently offline Balazs VarnaiFriend
Messages: 21
Registered: June 2011
Junior Member
Cosider the following grammar

Type:
	'type' name=ID 'maps' datatype=DataType;

enum DataType:
         boolean | integer;


If I input 'type boolean maps boolean', the editor highligths the first 'boolean' and complains that an ID is expected. When I try to reuse my 'boolean' definition later, for example as a reference, the editor still thinks it's the enum.

What is the quickest way to fix this? Thanks

Balazs
Re: Syntax highlight for Enums [message #691470 is a reply to message #691296] Fri, 01 July 2011 13:41 Go to previous message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
Enums become keywords and can thus not be matched by ID.
The simplest way to fix this is to list the keywords in a rule and then
use this rule instead of ID.

i.e. something like this:
Type: 'type' name=IDorKeyword 'maps' datatype = DataType ;
IDorKeyword : ID | 'boolean' | 'integer' | ... ;

The other alternative is to not use an Enum that is based on keywords
(you have to implement one yourself). I did something like that in
Eclipse/b3.

- henrik

On 7/1/11 9:28 AM, Balazs Varnai wrote:
> Cosider the following grammar
>
>
> Type:
> 'type' name=ID 'maps' datatype=DataType;
>
> enum DataType:
> boolean | integer;
>
>
> If I input 'type boolean maps boolean', the editor highligths the first
> 'boolean' and complains that an ID is expected. When I try to reuse my
> 'boolean' definition later, for example as a reference, the editor still
> thinks it's the enum.
>
> What is the quickest way to fix this? Thanks
>
> Balazs
Previous Topic:Showing Details/Descriptions in Content Assist
Next Topic:[XPAND] complexe SEPARATOR use
Goto Forum:
  


Current Time: Tue Sep 29 23:56:22 GMT 2020

Powered by FUDForum. Page generated in 0.01885 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top