请教一下用过xtext的朋友,xtext有没有将dsl文本解析为语法树的api,供我们通过操作语法树来得到dsl文本的各项信息这种能力?目前我根据它官网的教程,已经实现在自己的工作间创建xtext工程,编写dsl规则,并以此编译运行一个以此规则为sdk的新的虚拟工作台,我希望能把第一步插件化,在目标项目(而非一个虚拟的工作台)中引入此插件或jar包,实现对dsl编写时的自动提示与格式校验,有没有这种方法?
谢谢大家了。

解决方案 »

  1.   

    dsl解析的方法已经找到了,编写完规则后进行生成,就有解析器和模板类了,可直接用。
    插件化或嵌入其他工程的问题还没有解决。
      

  2.   

    不清楚你是要如何插件化,我看这里有一定量的关于plugin的介绍
    不知道符不符合http://www.eclipse.org/Xtext/documentation.html Xtext and JavaThe following chapter demonstrates how to integrate your own DSL with Java. We will do this in four stages: First, you will learn how to refer to existing Java elements from within your language. Then you will use Xbase to refer to generic types. In the third step, you will map your own DSL's concepts to Java concepts. Last but not least, you will use both Java types and your concepts within Xbase expressions and execute it.Throughout this chapter, we will step by step improve the domain model example from the tutorial.
    Plug-in Setup