Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Type Checking with JvmTypeParameter and JvmArgumentTypeReference
Type Checking with JvmTypeParameter and JvmArgumentTypeReference [message #876450] Thu, 24 May 2012 16:02 Go to next message
Victor Noël is currently offline Victor NoëlFriend
Messages: 60
Registered: April 2010
Member
Hi,

I am using xtext 2.3 with xbase and I'm trying to verify the conformance of types.

I have a grammar like that:
Component:
	"component" name=ValidID
	("[" typeParameters+=JvmTypeParameter ("," typeParameters+=JvmTypeParameter)* "]")?
	"{"
		(	provides+=ProvidedPort
		|	requires+=RequiredPort
		|	parts+=ComponentPart
		)*
	"}";

ComponentPart:
	("part") name=ValidID ":" componentReference=ParameterizedComponentReference ("{"
		(bindings+=Binding)*
 	"}")?;

ProvidedPort:
	"provides" name=ValidID ":" typeReference=JvmParameterizedTypeReference;

RequiredPort:
	"requires" name=ValidID ":" typeReference=JvmParameterizedTypeReference;

ComponentPart:
	("part") name=ValidID ":" componentReference=ParameterizedComponentReference ("{"
		(bindings+=Binding)*
 	"}")?;

Binding:
	"bind" from=[RequiredPort] "to" to=PartProvidedPortRef;

PartProvidedPortRef:
	(part=[Part|ValidID]|"this") "." port=[ProvidedPort];

ParameterizedComponentReference:
	component=[Component|QualifiedName] ("[" arguments+=JvmArgumentTypeReference ("," arguments+=JvmArgumentTypeReference)* "]")?;



Now my problem is that I would like to check with a TypeConformanceComputer that the from and the to features of Binding are conformant in terms of their types.
The thing is that depending on the way the ParameterizedComponentReference (for part) was parameterized, the JvmTypeParameter that are used in the JvmParameterizedTypeReference should be replaced with some JvmArgumentTypeReference.

So, I'm wondering what is the best way to get the actual type of the ProvidedPort and RequiredPort in the Binding according to their corresponding Part's ParameterizedComponentReference parameters.

I could implement something to do the replacement of these, but it is a huge job and was wondering if it wasn't already implemented in xbase...

Thank you!

Victor
Re: Type Checking with JvmTypeParameter and JvmArgumentTypeReference [message #876552 is a reply to message #876450] Thu, 24 May 2012 20:27 Go to previous message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Victor,

you'd usually implement getExpectedType and getType in order to perform
type checks. Things will almost work out of the box if you use the
JvmModelInferrer for that purpose (in other words: transform you domain
concepts to a corresponding Java model).

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 24.05.12 18:02, schrieb Victor Noël:
> Hi,
>
> I am using xtext 2.3 with xbase and I'm trying to verify the conformance
> of types.
>
> I have a grammar like that:
>
> Component:
> "component" name=ValidID
> ("[" typeParameters+=JvmTypeParameter (","
> typeParameters+=JvmTypeParameter)* "]")?
> "{"
> ( provides+=ProvidedPort
> | requires+=RequiredPort
> | parts+=ComponentPart
> )*
> "}";
>
> ComponentPart:
> ("part") name=ValidID ":"
> componentReference=ParameterizedComponentReference ("{"
> (bindings+=Binding)*
> "}")?;
>
> ProvidedPort:
> "provides" name=ValidID ":" typeReference=JvmParameterizedTypeReference;
>
> RequiredPort:
> "requires" name=ValidID ":" typeReference=JvmParameterizedTypeReference;
>
> ComponentPart:
> ("part") name=ValidID ":"
> componentReference=ParameterizedComponentReference ("{"
> (bindings+=Binding)*
> "}")?;
>
> Binding:
> "bind" from=[RequiredPort] "to" to=PartProvidedPortRef;
>
> PartProvidedPortRef:
> (part=[Part|ValidID]|"this") "." port=[ProvidedPort];
>
> ParameterizedComponentReference:
> component=[Component|QualifiedName] ("["
> arguments+=JvmArgumentTypeReference (","
> arguments+=JvmArgumentTypeReference)* "]")?;
>
>
>
> Now my problem is that I would like to check with a
> TypeConformanceComputer that the from and the to features of Binding are
> conformant in terms of their types.
> The thing is that depending on the way the
> ParameterizedComponentReference (for part) was parameterized, the
> JvmTypeParameter that are used in the JvmParameterizedTypeReference
> should be replaced with some JvmArgumentTypeReference.
>
> So, I'm wondering what is the best way to get the actual type of the
> ProvidedPort and RequiredPort in the Binding according to their
> corresponding Part's ParameterizedComponentReference parameters.
>
> I could implement something to do the replacement of these, but it is a
> huge job and was wondering if it wasn't already implemented in xbase...
>
> Thank you!
>
> Victor
Previous Topic:CrossReference Side-effect
Next Topic:importURI strange problems
Goto Forum:
  


Current Time: Thu Mar 28 17:38:03 GMT 2024

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

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

Back to the top