|
|
Re: Inferred superclasses [message #652716 is a reply to message #652705] |
Sat, 05 February 2011 20:15 |
Sebastian Zarnekow Messages: 3118 Registered: July 2009 |
Senior Member |
|
|
Hi Ralf,
I bet it's time to refactor to an imported metamodel ;-)
You could try to use the postprocessor but I'd not recommend that.
Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 05.02.11 19:02, schrieb Ralf Ebert:
> Hi,
>
> I'm using artificial parser rules like
>
> CommonSuperType: // unused
> SubTypeA | SubTypeB | SubTypeC;
>
> to get a super type inferred in the resulting model. While
> CommonSuperType should be never called, the generation still complains
> about being able to match input using multiple alternatives. Is it safe
> to ignore such a warning for an unused rule? And if so, is there a way
> to get rid of the warning?
>
> Also, is there a technique to make a class a subclass of another class
> without creating artificial rules/classes and without affecting the
> grammar, solely for shaping the result model? Like in,
>
> TypeA: 'foo' name=ID;
> TypeB: 'bar' name=ID;
>
> is there a way to get TypeB to extend TypeA in the model? The closest
> thing I found is
>
> TypeB returns TypeA:
> {TypeB} 'bar' name=ID;
>
> But this also changes the type of references to TypeB to TypeA.
>
> Thanks,
> Greetings,
> Ralf
|
|
|
|
|
Re: Inferred superclasses [message #652738 is a reply to message #652732] |
Sat, 05 February 2011 23:46 |
Sebastian Zarnekow Messages: 3118 Registered: July 2009 |
Senior Member |
|
|
Hi Ralf,
the transformation uses a somewhat limited algorithm to identify
uncalled rules. It does not work transitively. That explains your
observation.
Regarding your suggestion I doubt that the grammar is the right format
to define an ecore model thus I'd not introduce another concept for the
sake the generated metamodel.
Imported metamodels allow to define e.g. derived properties, super types
to factor common concepts into own types or define enum default values
explicitly.
Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 05.02.11 23:35, schrieb Ralf Ebert:
> Hi Sebastian,
>
>> I bet it's time to refactor to an imported metamodel ;-)
>> You could try to use the postprocessor but I'd not recommend that.
>
> but except for the inheritance structure the inferred model is pretty
> ok; does managing this manually instead of generating it has other
> advantages besides the inheritance which would justify the additional
> effort to update the model everytime the grammar changes?
>
> Also, I digged a bit deeper; the warning happens because I try to get a
> supertype for a supertype, see my answer to Alexanders message for an
> example.
>
> I also wondered, just out of curiosity, wouldn't it make sense to have
> some kind of syntax to tell Xtext that some rule should extend some
> other rule, affecting only the model?
>
> For example, I would like to refactor this:
>
> TypedName:
> Parameter | Property | Assignment;
>
> Parameter:
> typeRef=TypeReference name=ID;
>
> Property:
> typeRef=TypeReference name=ID;
>
> Assignment:
> typeRef=TypeReference name=ID '=' value=ProviderConstruction;
>
>
> to something like this:
>
> TypedName:
> typeRef=TypeReference name=ID;
>
> Parameter extends TypedName;
>
> Property extends TypedName;
>
> Assignment extends TypedName:
> typeRef=TypeReference name=ID '=' value=ProviderConstruction;
>
> Ralf
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03085 seconds