|
|
|
Re: Attaching keywords to variables within Xbase expressions [message #1021352 is a reply to message #1020925] |
Tue, 19 March 2013 22:57 |
Hallvard Traetteberg Messages: 673 Registered: July 2009 Location: Trondheim, Norway |
Senior Member |
|
|
Hi,
I think you'll have to extend XEqualityExpression in a subclass that
includes the boolean special field, and then use a parser action to
indicate that it should create an instance of that subclass:
XEqualityExpression returns XExpression:
{MyXEqualitySubclass} (special ?= 'special')? XRelationalExpression
(=>({XBinaryOperation.leftOperand=current}
feature=[types::JvmIdentifiableElement|OpEquality])
rightOperand=XRelationalExpression)*;
Hallvard
On 19.03.13 00.40, Oren Mishali wrote:
> Thanks Sebastian,
>
> I've tried the approach you have suggested. I've extended
> XEqualityExpression as follows (note the addition of the new 'special'
> keyword):
>
> XEqualityExpression returns XExpression:
> 'special' ? XRelationalExpression
> (=>({XBinaryOperation.leftOperand=current}
> feature=[types::JvmIdentifiableElement|OpEquality])
> rightOperand=XRelationalExpression)*;
>
> This change indeed allows to write Xbase expressions such as:
>
> (special x == 3)
>
> Next, I've tried to add a new variable in order to know whether the new
> 'special' keyword was added:
>
> XEqualityExpression returns XExpression:
> (special ?= 'special')? XRelationalExpression
> (=>({XBinaryOperation.leftOperand=current}
> feature=[types::JvmIdentifiableElement|OpEquality])
> rightOperand=XRelationalExpression)*;
>
> Unfortunately, I get the following two errors:
>
> Cannot find compatible feature special in sealed EClass XExpression from
> imported package http://www.eclipse.org/xtext/xbase/Xbase: The type
> 'XExpression' does not have a feature 'special'.
>
> An unassigned rule call is not allowed, when the 'current' was already
> created.
>
> Thanks,
> Oren
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.02964 seconds