|
Re: Type Checking with JvmTypeParameter and JvmArgumentTypeReference [message #876552 is a reply to message #876450] |
Thu, 24 May 2012 20:27 |
Sebastian Zarnekow 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
|
|
|
Powered by
FUDForum. Page generated in 0.02318 seconds