Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » "hidden assignments" in parser rules
"hidden assignments" in parser rules [message #553231] Mon, 16 August 2010 17:20 Go to next message
Christian Schneider is currently offline Christian SchneiderFriend
Messages: 23
Registered: July 2009
Junior Member
Dear all,

recently, I realized that the Xtext editor accepts assignments of
concrete values to an attribute of the object the parser rule/rule call
is in charge of. The code generation is working properly, too.

I tested it with an ID, i.e. EString, attribute (the meta model is
imported) like:

CommentAnnotation returns Annotation:
name="comment" value = STRING;

KeyValueAnnotation returns Annotation:
name=ID value= STRING;

However, in the test environment the xtext validator of the concrete
editor complained about no viable input/assignment to the attribute
(here: during CommentAnnotation concerning the name attribute).

Hence, my question is:
What is the current state of that part of Xtext (or did I do something
wrong, maybe)?

cheers,
Christian
Re: "hidden assignments" in parser rules [message #553248 is a reply to message #553231] Mon, 16 August 2010 19:31 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hello Christian,

can you tell more about the context the rules are used:

i tried following:

<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
    xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="test"
    nsURI="http://www.eclipse.org/test" nsPrefix="test">
  <eClassifiers xsi:type="ecore:EClass" name="Model">
    <eStructuralFeatures xsi:type="ecore:EReference" name="annotations" upperBound="-1"
        eType="#//Annotation" containment="true"/>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="Annotation">
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="value" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
  </eClassifiers>
</ecore:EPackage>


grammar org.xtext.example.mydsl2.MyDsl2 with org.eclipse.xtext.common.Terminals 

import "platform:/resource/test/model/test.ecore" 

import "http://www.eclipse.org/emf/2002/Ecore" as ecore

Model:
	annotations+=CommentAnnotation*
	annotations+=KeyValueAnnotation*
;

CommentAnnotation returns Annotation:
name="comment" value = STRING;

KeyValueAnnotation returns Annotation:
name=ID value= STRING;


comment "a"
comment "b"
x "y"


and it works for me

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: "hidden assignments" in parser rules [message #553372 is a reply to message #553248] Tue, 17 August 2010 09:54 Go to previous messageGo to next message
Christian Schneider is currently offline Christian SchneiderFriend
Messages: 23
Registered: July 2009
Junior Member
Hi,

I'm afraid I confused different things!

In this case

> CommentAnnotation returns Annotation:
> name="comment" value = STRING;

"comment" serves as a keyword and is written to name feature
if the rule matches, i.e. "comment" is present (I usually put keywords in single quotes).

What I actually want to achieve is to make the assignment without
mentioning the keyword in the text, like a semantic action in traditional parser generators.

To be in more detail:

In our models we want to declare different sorts of signals:
input, output, inputoutput, local

Our meta model contains a signal class with boolean flags isInput, isOutput.

Thus, I want to write the grammar like

Model:
.
.
'input' signals+=InputSignal (',' signals+=InputSignal)*
|'inputoutput' signals+=InputOutputSignal (',' signals+=InputOutputSignal)*
.
.
.
;

InputSignal returns Signal:
<hidden isInputs=true> name=ID;

InputOutputSignal returns Signal:
<hidden isInputs=true isOutput=true> name=ID;


Would this be possible?

Best,
Christian

On 8/16/10 9:31 PM, Christian Dietrich wrote:
> Hello Christian,
>
> can you tell more about the context the rules are used:
>
> i tried following:
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <ecore:EPackage xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="test"
> nsURI="http://www.eclipse.org/test" nsPrefix="test">
> <eClassifiers xsi:type="ecore:EClass" name="Model">
> <eStructuralFeatures xsi:type="ecore:EReference" name="annotations"
> upperBound="-1"
> eType="#//Annotation" containment="true"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Annotation">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="value"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> </eClassifiers>
> </ecore:EPackage>
>
>
>
> grammar org.xtext.example.mydsl2.MyDsl2 with
> org.eclipse.xtext.common.Terminals
> import "platform:/resource/test/model/test.ecore"
> import "http://www.eclipse.org/emf/2002/Ecore" as ecore
>
> Model:
> annotations+=CommentAnnotation*
> annotations+=KeyValueAnnotation*
> ;
>
> CommentAnnotation returns Annotation:
> name="comment" value = STRING;
>
> KeyValueAnnotation returns Annotation:
> name=ID value= STRING;
>
>
>
> comment "a"
> comment "b"
> x "y"
>
>
> and it works for me
>
> ~Christian
Re: "hidden assignments" in parser rules [message #553692 is a reply to message #553372] Wed, 18 August 2010 13:30 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
You can use something like
Rule : aBooleanAttribute =? 'keyword' ;

To set a boolean if the keyword is present.

- henrik

On 8/17/10 11:54 AM, Christian Schneider wrote:
> Hi,
>
> I'm afraid I confused different things!
>
> In this case
>
>> CommentAnnotation returns Annotation:
>> name="comment" value = STRING;
>
> "comment" serves as a keyword and is written to name feature
> if the rule matches, i.e. "comment" is present (I usually put keywords in single quotes).
>
> What I actually want to achieve is to make the assignment without
> mentioning the keyword in the text, like a semantic action in traditional parser generators.
>
> To be in more detail:
>
> In our models we want to declare different sorts of signals:
> input, output, inputoutput, local
>
> Our meta model contains a signal class with boolean flags isInput, isOutput.
>
> Thus, I want to write the grammar like
>
> Model:
> .
> .
> 'input' signals+=InputSignal (',' signals+=InputSignal)*
> |'inputoutput' signals+=InputOutputSignal (',' signals+=InputOutputSignal)*
> .
> .
> .
> ;
>
> InputSignal returns Signal:
> <hidden isInputs=true> name=ID;
>
> InputOutputSignal returns Signal:
> <hidden isInputs=true isOutput=true> name=ID;
>
>
> Would this be possible?
>
> Best,
> Christian
>
> On 8/16/10 9:31 PM, Christian Dietrich wrote:
>> Hello Christian,
>>
>> can you tell more about the context the rules are used:
>>
>> i tried following:
>>
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <ecore:EPackage xmi:version="2.0"
>> xmlns:xmi="http://www.omg.org/XMI"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="test"
>> nsURI="http://www.eclipse.org/test" nsPrefix="test">
>> <eClassifiers xsi:type="ecore:EClass" name="Model">
>> <eStructuralFeatures xsi:type="ecore:EReference" name="annotations"
>> upperBound="-1"
>> eType="#//Annotation" containment="true"/>
>> </eClassifiers>
>> <eClassifiers xsi:type="ecore:EClass" name="Annotation">
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="value"
>> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>> </eClassifiers>
>> </ecore:EPackage>
>>
>>
>>
>> grammar org.xtext.example.mydsl2.MyDsl2 with
>> org.eclipse.xtext.common.Terminals
>> import "platform:/resource/test/model/test.ecore"
>> import "http://www.eclipse.org/emf/2002/Ecore" as ecore
>>
>> Model:
>> annotations+=CommentAnnotation*
>> annotations+=KeyValueAnnotation*
>> ;
>>
>> CommentAnnotation returns Annotation:
>> name="comment" value = STRING;
>>
>> KeyValueAnnotation returns Annotation:
>> name=ID value= STRING;
>>
>>
>>
>> comment "a"
>> comment "b"
>> x "y"
>>
>>
>> and it works for me
>>
>> ~Christian
>
Re: "hidden assignments" in parser rules [message #553946 is a reply to message #553692] Thu, 19 August 2010 13:39 Go to previous messageGo to next message
Christian Schneider is currently offline Christian SchneiderFriend
Messages: 23
Registered: July 2009
Junior Member
Of course! :-)

But I want to set a (or more) boolean(s) just by calling a rule, WITHOUT
any keyword consumption!

cheers,
Christian

On 8/18/10 3:30 PM, Henrik Lindberg wrote:
> You can use something like
> Rule : aBooleanAttribute =? 'keyword' ;
>
> To set a boolean if the keyword is present.
>
> - henrik
>
> On 8/17/10 11:54 AM, Christian Schneider wrote:
>> Hi,
>>
>> I'm afraid I confused different things!
>>
>> In this case
>>
>>> CommentAnnotation returns Annotation:
>>> name="comment" value = STRING;
>>
>> "comment" serves as a keyword and is written to name feature
>> if the rule matches, i.e. "comment" is present (I usually put keywords
>> in single quotes).
>>
>> What I actually want to achieve is to make the assignment without
>> mentioning the keyword in the text, like a semantic action in
>> traditional parser generators.
>>
>> To be in more detail:
>>
>> In our models we want to declare different sorts of signals:
>> input, output, inputoutput, local
>>
>> Our meta model contains a signal class with boolean flags isInput,
>> isOutput.
>>
>> Thus, I want to write the grammar like
>>
>> Model:
>> .
>> .
>> 'input' signals+=InputSignal (',' signals+=InputSignal)*
>> |'inputoutput' signals+=InputOutputSignal (','
>> signals+=InputOutputSignal)*
>> .
>> .
>> .
>> ;
>>
>> InputSignal returns Signal:
>> <hidden isInputs=true> name=ID;
>>
>> InputOutputSignal returns Signal:
>> <hidden isInputs=true isOutput=true> name=ID;
>>
>>
>> Would this be possible?
>>
>> Best,
>> Christian
>>
>> On 8/16/10 9:31 PM, Christian Dietrich wrote:
>>> Hello Christian,
>>>
>>> can you tell more about the context the rules are used:
>>>
>>> i tried following:
>>>
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <ecore:EPackage xmi:version="2.0"
>>> xmlns:xmi="http://www.omg.org/XMI"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="test"
>>> nsURI="http://www.eclipse.org/test" nsPrefix="test">
>>> <eClassifiers xsi:type="ecore:EClass" name="Model">
>>> <eStructuralFeatures xsi:type="ecore:EReference" name="annotations"
>>> upperBound="-1"
>>> eType="#//Annotation" containment="true"/>
>>> </eClassifiers>
>>> <eClassifiers xsi:type="ecore:EClass" name="Annotation">
>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>>> eType="ecore:EDataType
>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="value"
>>> eType="ecore:EDataType
>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>> </eClassifiers>
>>> </ecore:EPackage>
>>>
>>>
>>>
>>> grammar org.xtext.example.mydsl2.MyDsl2 with
>>> org.eclipse.xtext.common.Terminals
>>> import "platform:/resource/test/model/test.ecore"
>>> import "http://www.eclipse.org/emf/2002/Ecore" as ecore
>>>
>>> Model:
>>> annotations+=CommentAnnotation*
>>> annotations+=KeyValueAnnotation*
>>> ;
>>>
>>> CommentAnnotation returns Annotation:
>>> name="comment" value = STRING;
>>>
>>> KeyValueAnnotation returns Annotation:
>>> name=ID value= STRING;
>>>
>>>
>>>
>>> comment "a"
>>> comment "b"
>>> x "y"
>>>
>>>
>>> and it works for me
>>>
>>> ~Christian
>>
>
Re: "hidden assignments" in parser rules [message #553986 is a reply to message #553946] Thu, 19 August 2010 15:21 Go to previous messageGo to next message
Meinte Boersma is currently offline Meinte BoersmaFriend
Messages: 434
Registered: July 2009
Location: Leiden, Netherlands
Senior Member
Well, something's got to trigger the setting of the boolean... A parser rule only actually matches if any of its non-optional parts (keywords, other rule calls) match.

Maybe you can move the "setting of the boolean" to a specific sub type of the type corresponding to the parser rule using an unassigned action?


Re: "hidden assignments" in parser rules [message #554245 is a reply to message #553946] Fri, 20 August 2010 17:23 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
As it is not supported to call arbitrary methods from the grammar the
options I come to think of are:
- assign to feature (boolean or other) and modify assignment to have
side effects (as suggested earlier)
- use subclasses that sets the values in question in their constructors
- change the factory that is used by the parser to create model instances
- post processing

Regards
- henrik

On 8/19/10 3:39 PM, Christian Schneider wrote:
> Of course! :-)
>
> But I want to set a (or more) boolean(s) just by calling a rule, WITHOUT
> any keyword consumption!
>
> cheers,
> Christian
>
> On 8/18/10 3:30 PM, Henrik Lindberg wrote:
>> You can use something like
>> Rule : aBooleanAttribute =? 'keyword' ;
>>
>> To set a boolean if the keyword is present.
>>
>> - henrik
>>
>> On 8/17/10 11:54 AM, Christian Schneider wrote:
>>> Hi,
>>>
>>> I'm afraid I confused different things!
>>>
>>> In this case
>>>
>>>> CommentAnnotation returns Annotation:
>>>> name="comment" value = STRING;
>>>
>>> "comment" serves as a keyword and is written to name feature
>>> if the rule matches, i.e. "comment" is present (I usually put keywords
>>> in single quotes).
>>>
>>> What I actually want to achieve is to make the assignment without
>>> mentioning the keyword in the text, like a semantic action in
>>> traditional parser generators.
>>>
>>> To be in more detail:
>>>
>>> In our models we want to declare different sorts of signals:
>>> input, output, inputoutput, local
>>>
>>> Our meta model contains a signal class with boolean flags isInput,
>>> isOutput.
>>>
>>> Thus, I want to write the grammar like
>>>
>>> Model:
>>> .
>>> .
>>> 'input' signals+=InputSignal (',' signals+=InputSignal)*
>>> |'inputoutput' signals+=InputOutputSignal (','
>>> signals+=InputOutputSignal)*
>>> .
>>> .
>>> .
>>> ;
>>>
>>> InputSignal returns Signal:
>>> <hidden isInputs=true> name=ID;
>>>
>>> InputOutputSignal returns Signal:
>>> <hidden isInputs=true isOutput=true> name=ID;
>>>
>>>
>>> Would this be possible?
>>>
>>> Best,
>>> Christian
>>>
>>> On 8/16/10 9:31 PM, Christian Dietrich wrote:
>>>> Hello Christian,
>>>>
>>>> can you tell more about the context the rules are used:
>>>>
>>>> i tried following:
>>>>
>>>>
>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>> <ecore:EPackage xmi:version="2.0"
>>>> xmlns:xmi="http://www.omg.org/XMI"
>>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="test"
>>>> nsURI="http://www.eclipse.org/test" nsPrefix="test">
>>>> <eClassifiers xsi:type="ecore:EClass" name="Model">
>>>> <eStructuralFeatures xsi:type="ecore:EReference" name="annotations"
>>>> upperBound="-1"
>>>> eType="#//Annotation" containment="true"/>
>>>> </eClassifiers>
>>>> <eClassifiers xsi:type="ecore:EClass" name="Annotation">
>>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>>>> eType="ecore:EDataType
>>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="value"
>>>> eType="ecore:EDataType
>>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>> </eClassifiers>
>>>> </ecore:EPackage>
>>>>
>>>>
>>>>
>>>> grammar org.xtext.example.mydsl2.MyDsl2 with
>>>> org.eclipse.xtext.common.Terminals
>>>> import "platform:/resource/test/model/test.ecore"
>>>> import "http://www.eclipse.org/emf/2002/Ecore" as ecore
>>>>
>>>> Model:
>>>> annotations+=CommentAnnotation*
>>>> annotations+=KeyValueAnnotation*
>>>> ;
>>>>
>>>> CommentAnnotation returns Annotation:
>>>> name="comment" value = STRING;
>>>>
>>>> KeyValueAnnotation returns Annotation:
>>>> name=ID value= STRING;
>>>>
>>>>
>>>>
>>>> comment "a"
>>>> comment "b"
>>>> x "y"
>>>>
>>>>
>>>> and it works for me
>>>>
>>>> ~Christian
>>>
>>
>
Re: "hidden assignments" in parser rules [message #554601 is a reply to message #554245] Mon, 23 August 2010 16:25 Go to previous messageGo to next message
Christian Schneider is currently offline Christian SchneiderFriend
Messages: 23
Registered: July 2009
Junior Member
Hi,

On 8/20/10 7:23 PM, Henrik Lindberg wrote:
> As it is not supported to call arbitrary methods from the grammar the
> options I come to think of are:
> - assign to feature (boolean or other) and modify assignment to have
> side effects (as suggested earlier)
> - use subclasses that sets the values in question in their constructors

That might be a reasonable option on the parsing side.

However, I'm not convinced whether this will work on the serializing
side if the model was constructed outside of Xtext, e.g. programmatically.

For instance: parsing of

input A,B,C
output O
inputoutput P,Q
local L

seems to be easy while serializing such a string seems to be hard to me
if the source is just a list of objects of type 'signal' (with different
boolean attribute settings).

Finally, my question to the Xtext developer is:

Is support of such functionalities on your road map
and, if so, is it for the short or long term?


cheers,
Christian



> - change the factory that is used by the parser to create model instances
> - post processing
>
> Regards
> - henrik
>
> On 8/19/10 3:39 PM, Christian Schneider wrote:
>> Of course! :-)
>>
>> But I want to set a (or more) boolean(s) just by calling a rule, WITHOUT
>> any keyword consumption!
>>
>> cheers,
>> Christian
>>
>> On 8/18/10 3:30 PM, Henrik Lindberg wrote:
>>> You can use something like
>>> Rule : aBooleanAttribute =? 'keyword' ;
>>>
>>> To set a boolean if the keyword is present.
>>>
>>> - henrik
>>>
>>> On 8/17/10 11:54 AM, Christian Schneider wrote:
>>>> Hi,
>>>>
>>>> I'm afraid I confused different things!
>>>>
>>>> In this case
>>>>
>>>>> CommentAnnotation returns Annotation:
>>>>> name="comment" value = STRING;
>>>>
>>>> "comment" serves as a keyword and is written to name feature
>>>> if the rule matches, i.e. "comment" is present (I usually put keywords
>>>> in single quotes).
>>>>
>>>> What I actually want to achieve is to make the assignment without
>>>> mentioning the keyword in the text, like a semantic action in
>>>> traditional parser generators.
>>>>
>>>> To be in more detail:
>>>>
>>>> In our models we want to declare different sorts of signals:
>>>> input, output, inputoutput, local
>>>>
>>>> Our meta model contains a signal class with boolean flags isInput,
>>>> isOutput.
>>>>
>>>> Thus, I want to write the grammar like
>>>>
>>>> Model:
>>>> .
>>>> .
>>>> 'input' signals+=InputSignal (',' signals+=InputSignal)*
>>>> |'inputoutput' signals+=InputOutputSignal (','
>>>> signals+=InputOutputSignal)*
>>>> .
>>>> .
>>>> .
>>>> ;
>>>>
>>>> InputSignal returns Signal:
>>>> <hidden isInputs=true> name=ID;
>>>>
>>>> InputOutputSignal returns Signal:
>>>> <hidden isInputs=true isOutput=true> name=ID;
>>>>
>>>>
>>>> Would this be possible?
>>>>
>>>> Best,
>>>> Christian
>>>>
>>>> On 8/16/10 9:31 PM, Christian Dietrich wrote:
>>>>> Hello Christian,
>>>>>
>>>>> can you tell more about the context the rules are used:
>>>>>
>>>>> i tried following:
>>>>>
>>>>>
>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>> <ecore:EPackage xmi:version="2.0"
>>>>> xmlns:xmi="http://www.omg.org/XMI"
>>>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>>> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="test"
>>>>> nsURI="http://www.eclipse.org/test" nsPrefix="test">
>>>>> <eClassifiers xsi:type="ecore:EClass" name="Model">
>>>>> <eStructuralFeatures xsi:type="ecore:EReference"
>>>>> name="annotations"
>>>>> upperBound="-1"
>>>>> eType="#//Annotation" containment="true"/>
>>>>> </eClassifiers>
>>>>> <eClassifiers xsi:type="ecore:EClass" name="Annotation">
>>>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>>>>> eType="ecore:EDataType
>>>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="value"
>>>>> eType="ecore:EDataType
>>>>> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>>> </eClassifiers>
>>>>> </ecore:EPackage>
>>>>>
>>>>>
>>>>>
>>>>> grammar org.xtext.example.mydsl2.MyDsl2 with
>>>>> org.eclipse.xtext.common.Terminals
>>>>> import "platform:/resource/test/model/test.ecore"
>>>>> import "http://www.eclipse.org/emf/2002/Ecore" as ecore
>>>>>
>>>>> Model:
>>>>> annotations+=CommentAnnotation*
>>>>> annotations+=KeyValueAnnotation*
>>>>> ;
>>>>>
>>>>> CommentAnnotation returns Annotation:
>>>>> name="comment" value = STRING;
>>>>>
>>>>> KeyValueAnnotation returns Annotation:
>>>>> name=ID value= STRING;
>>>>>
>>>>>
>>>>>
>>>>> comment "a"
>>>>> comment "b"
>>>>> x "y"
>>>>>
>>>>>
>>>>> and it works for me
>>>>>
>>>>> ~Christian
>>>>
>>>
>>
>
Re: "hidden assignments" in parser rules [message #554638 is a reply to message #553372] Mon, 23 August 2010 19:22 Go to previous message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
Am 8/17/10 11:54 AM, schrieb Christian Schneider:
> Model:
> .
> .
> 'input' signals+=InputSignal (',' signals+=InputSignal)*
> |'inputoutput' signals+=InputOutputSignal (',' signals+=InputOutputSignal)*
> .
> .
> .
> ;
>
> InputSignal returns Signal:
> <hidden isInputs=true> name=ID;
>
> InputOutputSignal returns Signal:
> <hidden isInputs=true isOutput=true> name=ID;
>
>
> Would this be possible?

No, but you could have different subtypes for the different inputs:

InputSignal : name=ID;
InputOutputSignal : name=ID;

//and if you infer the ecore model
You write

Signal : InputSignal|InputOuputSignal;

This has the advantage that you can dispatch using the type and don't
need to rely on boolean flags.

If you still need the boolean flags, you could make the transient and
derived features and implement them per type.

> Is support of such functionalities on your road map
> and, if so, is it for the short or long term?

No it's not on the road map, but similar things have been requested
before so we might do something about it in the future ...

Sven

--
--
Need professional support for Xtext or other Eclipse Modeling technologies?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : http://blog.efftinge.de
Previous Topic:Determining DSL location from AST
Next Topic:Run Xtext generator from buckminster: Problems with initial setup and after grammar changes
Goto Forum:
  


Current Time: Thu Apr 25 08:44:11 GMT 2024

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

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

Back to the top