0

在 Eclipse 建模框架 (EMF) 中,有用于定义模型的 ecore 文件。从这个模型代码(和其他东西)可以生成。该生成步骤由“EMF 生成器模型”描述。现在我的问题是,为什么这个文件被称为“模型”而不是“配置”或类似的东西。在我看来,它没有建模任何东西,但它描述了一个生成步骤......

4

3 回答 3

3

EMF 的当前实现是使用引导方法创建的。起初,描述存储在 ecore 和 genmodel 中的数据的模型是手工编写的。一旦 EMF 足够稳定,它们就会被 EMF 本身建模和生成。这意味着,ecore 和 genmodel 在任何方面都是 EMF 模型。

这类似于为新的编程语言开发了多少编译器。初始实现必须用第二种语言编写,但一旦编译器完成,您就可以使用新语言编写新实现,添加功能,然后使用之前版本编译器的二进制文件来创建下一个。

来自 EMF 的创建者 Ed Merks:

毕竟,EMF 的生成器模型会生成 Ecore 模型和自身,因此我们实际上无法删除我们生成的代码。我们需要它来引导环境。这是个棘手的问题。 http://ed-merks.blogspot.de/2008/10/hand-written-and-generated-code-never.html

于 2013-03-30T08:44:38.323 回答
3

While the other answers are perfectly correct, there is one additional difference between a "model" and a "configuration". All EMF models (including this generator model) can be modified, transformed and so on by every already available EMF tool (because they all use the same meta model).

This is a huge difference compared to the situation that the configuration can only be read by another tool, if it knows the exact format of the configuration serialization.

So you can create an UML diagram of the generator model, you can use it in a model based graphical editor, you can transform it using model-to-model transformation plugins, you can put it into EMFstore, ... without any of these tools having been prepared specifically for that model.

于 2013-03-30T15:33:11.443 回答
2

实际上,从技术上讲genmodel,这些ecore文件也是 EMF 模型。因此,以这种方式调用它并不奇怪。

事实上,您必须了解 EMF 允许描述任何类型的结构化信息。所以它可以用来描述你自己的语义以及描述代码生成配置甚至描述自己(ecore)。

于 2013-03-29T22:29:28.483 回答