Home » Modeling » TMF (Xtext) » Boolean NOT assignment?
Boolean NOT assignment? [message #62932] |
Thu, 23 July 2009 11:10  |
Eclipse User |
|
|
|
In Xtext I can write a rule as follows:
m property ?= "keyword"
which assigns true to the property of the keyword is there.
This work only for properties where the default is false.
I have properties that have true as their default value.
Can I do something like
property != "keyword"
to assign false to the property whenever the keyword is there?
Jos
|
|
| | |
Re: Boolean NOT assignment? [message #62978 is a reply to message #62952] |
Fri, 24 July 2009 07:47   |
Eclipse User |
|
|
|
Originally posted by: oba.informatik.uni-kiel.de
Hi all,
I find this discussion interesting.
The first thing, I thought, would do was something like this:
terminal NOTKEYWORD: !'keyword';
Foo: property?=NOTKEYWORD;
But this doesn't even compile (due to (a) syntax error(s)). Can someone
say, what my mistake is?
Thanks
mN
Knut Wannheden wrote:
> Hi Jos,
>
> Another workaround, as it's been done in the EcoreDsl example project,
> is to define custom terminal rules (see rules at bottom in
> http://tinyurl.com/nkvdmo) with a corresponding value converter
> (http://tinyurl.com/m7uap7). So e.g.
>
> Foo : property?=KEYWORD ;
>
> terminal KEYWORD returns ecore::EBoolean : "keyword" ;
>
> Regards,
>
> --knut
>
> Sebastian Zarnekow wrote:
>> Hi Jos,
>>
>> I'm afraid this is currently not possible. A feature request is
>> welcome :-)
>>
>> A workaround is to override the IAstFactory#set(..) and assign false
>> instead of true for your specific feature on a specific class. You'ld
>> have to ensure that true is default though.
>>
>> Thanks,
>> Sebastian
>>
|
|
|
Re: Boolean NOT assignment? [message #62982 is a reply to message #62978] |
Fri, 24 July 2009 08:17   |
Eclipse User |
|
|
|
Hi myName,
if this is everything what can be found in your grammar, the syntax
errors occur because you have to start your grammar with a parser rule.
However, the negated token ! means, parser anything at this place but
not the string "keyword". It has no semantics for the assignemnt in the
rule "Foo".
Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 24.07.2009 13:47 Uhr, schrieb myName:
> Hi all,
>
> I find this discussion interesting.
> The first thing, I thought, would do was something like this:
>
> terminal NOTKEYWORD: !'keyword';
> Foo: property?=NOTKEYWORD;
>
>
> But this doesn't even compile (due to (a) syntax error(s)). Can someone
> say, what my mistake is?
>
> Thanks
>
> mN
>
> Knut Wannheden wrote:
>
>
>
>> Hi Jos,
>>
>> Another workaround, as it's been done in the EcoreDsl example project,
>> is to define custom terminal rules (see rules at bottom in
>> http://tinyurl.com/nkvdmo) with a corresponding value converter
>> (http://tinyurl.com/m7uap7). So e.g.
>>
>> Foo : property?=KEYWORD ;
>>
>> terminal KEYWORD returns ecore::EBoolean : "keyword" ;
>>
>> Regards,
>>
>> --knut
>>
>> Sebastian Zarnekow wrote:
>>> Hi Jos,
>>>
>>> I'm afraid this is currently not possible. A feature request is
>>> welcome :-)
>>>
>>> A workaround is to override the IAstFactory#set(..) and assign false
>>> instead of true for your specific feature on a specific class. You'ld
>>> have to ensure that true is default though.
>>>
>>> Thanks,
>>> Sebastian
>>>
|
|
|
Re: Boolean NOT assignment? [message #62984 is a reply to message #62982] |
Fri, 24 July 2009 09:09   |
Eclipse User |
|
|
|
Originally posted by: oba.informatik.uni-kiel.de
Oh, I misunderstood two things then:
Sebastian Zarnekow wrote:
> Hi myName,
>
> if this is everything what can be found in your grammar, the syntax
> errors occur because you have to start your grammar with a parser rule.
So, Xtext takes the first rule in the grammar as the starting rule and
does _not_ go and search for the first _parser_ rule. Thanks for making
this clear to me.
> However, the negated token ! means, parser anything at this place but
> not the string "keyword". It has no semantics for the assignemnt in the
> rule "Foo".
So, the terminal rule:
terminal NOTKEYWORD: !'keyword';
would return an EString containing everything, I have written except the
word "keyword". So it would cause, that the rest of the file stays
untouched by the parser.
> Regards,
> Sebastian
Thanks a lot!
|
|
|
Re: Boolean NOT assignment? [message #62991 is a reply to message #62984] |
Fri, 24 July 2009 09:46   |
Eclipse User |
|
|
|
Hi myName,
please see below.
Am 24.07.2009 15:09 Uhr, schrieb myName:
> Oh, I misunderstood two things then:
>
> Sebastian Zarnekow wrote:
>> Hi myName,
>>
>> if this is everything what can be found in your grammar, the syntax
>> errors occur because you have to start your grammar with a parser rule.
>
> So, Xtext takes the first rule in the grammar as the starting rule and
> does _not_ go and search for the first _parser_ rule. Thanks for making
> this clear to me.
Exactly.
>
>> However, the negated token ! means, parser anything at this place but
>> not the string "keyword". It has no semantics for the assignemnt in the
>> rule "Foo".
> So, the terminal rule:
>
> terminal NOTKEYWORD: !'keyword';
>
> would return an EString containing everything, I have written except the
> word "keyword". So it would cause, that the rest of the file stays
> untouched by the parser.
This rule would consume exactly one character if only if the following
sequence of characters is not "keyword".
>
>> Regards,
>> Sebastian
> Thanks a lot!
Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
|
|
| | |
Goto Forum:
Current Time: Tue Jul 08 03:41:19 EDT 2025
Powered by FUDForum. Page generated in 0.28229 seconds
|