问题描述
两个小时前我才刚开始阅读有关DSL建模的信息。
I've just started a couple of hours ago reading about DSL modeling.
但是现在,我只能使用JetBrains MPS IDE或JetBrains Intellij Idea的插件并且我想知道如何将那些DSL模型导出到可用于例如控制台应用程序或其他任何应用程序(如果有可能,或者说得通)。
But right now, I'm tied to using the JetBrains MPS IDE or it's plugin for JetBrains Intellij Idea and I'd like to know how can I export those DSL models to something available to use for e.g. console applications or whatever (in case it's possible or it makes sense).
推荐答案
您可以定义生成器来转换句子(文件(AST)文件转换为另一种MPS语言。目标语言必须首先存在于MPS中。
You can define a generator which transforms a sentence (file, AST) of your language into another MPS language. The target language must exist in MPS first.
或者,您可以使用TextGen方面生成文本,但这更适合只打印您的语言的文本表示形式。如果您想要更复杂的功能(例如生成另一种语言的文本代码),则可以使用或。
Alternatively, you could generate text with the TextGen aspect, but that is more suitable to just print the textual representation of your language. If you would like something more sophisticated (like generating text code of another language), you can use plaintextgen language from MPS-extensions or mbeddr.platform.
如果要将文本程序输入(导入)到MPS 可以更改AST的存储格式(从XML更改为直接语言,但这又需要解析器读取),并带有。
If you want to input (import) a textual program into MPS you can change the format in which the AST is stored (from XML to maybe directly your language, but this would again require a parser to read) with custom persistence.
我目前正在研究,它可以从模型(基于模型)中导入MPS语言解析器生成器,其中输入不是语法,而是表示语义模型的Java类。然后,您可以导入一个句子(文件),该句子创建并填充模型(AST)。从MPS中的程序中,您可以生成填充原始Java类的Java源代码。因此,如果您希望使用文本MPS语言并使用IDE,然后将AST导出到可以使用的Java对象中,也许YtM适合您。
I am currently working on a solution which enables to import an MPS language from a YAJCo model (model-based parser generator, where the input is not a grammar, but Java classes representing the semantic model). Then you can import a sentence (file) which creates and populates a model (AST). From the program in MPS you can generate Java source code which fills the original Java classes. So if you want a textual MPS language and use the IDE but then export the AST into Java objects you can use, maybe YtM is for you.
这篇关于我可以使用JetBrains MPS内生成的DSL语言做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!