| Exclude keywords in certain context [message #922627] |
Tue, 25 September 2012 03:21  |
Tu Do Messages: 21 Registered: August 2012 |
Junior Member |
|
|
In some certain rules, I want to treat some keywords as normal ID. How do I do that? For example:
ENUM:
'enum' ID '{' ( literal = ID ('=' INT)? ','? )+ '}' ';'
FREE:
'FREE' ID ';'
Example code of the above grammar should be like this:
enum State {
BUSY = 1,
FREE
}
I declared 'FREE' as a keyword. Xtext will highlight 'FREE' in enum as an error and require me to write according to FREE rule. How can I exclude FREE rule in ENUM rule?
|
|
|
|
|
|
| Re: Exclude keywords in certain context [message #923761 is a reply to message #923731] |
Wed, 26 September 2012 03:13   |
Tu Do Messages: 21 Registered: August 2012 |
Junior Member |
|
|
Christian Dietrich wrote on Wed, 26 September 2012 02:30Hi,
you can adapt highlighting
~Christian
As far as I know, I can only highlight static keyword. The highlighted keyword will be applied everywhere it is seen in my language. So, if every constant in my enum type is highlighted with Black, except a constant which is highlighted as red. If I highlighted the keyword to be the same as the constants, it will lose the keyword markup.
Certainly, I don't want to markup constant elements of enum the same as my keywords. Or is there a way to highlight according to the current rule?
[Updated on: Wed, 26 September 2012 03:16] Report message to a moderator
|
|
|
|
|
| Re: Exclude keywords in certain context [message #924142 is a reply to message #923848] |
Wed, 26 September 2012 10:46  |
Henrik Lindberg Messages: 2428 Registered: July 2009 |
Senior Member |
|
|
On 2012-26-09 1:41, Christian Dietrich wrote:
> You can fix this using semantic highlighting. We do this in our project
> - I cannot give you the code for copyright issues
>
For an example look at
org.cloudsmith.geppetto.pp.dsl.ui.coloring.PPSemanticHighlightingCalculator
in project cloudsmith / geppetto @ github - it uses several different
ways of highlighting.
- henrik
|
|
|
Powered by
FUDForum. Page generated in 0.04811 seconds