相关疑难解决方法(0)

将Xtext与StringTemplate代码生成器链接

在我当前的项目中,我试图链接用xtext编写的DSL规范和用StringTemplate编写的代码生成器.

例如,我的DSL规范的语法如下.我通过xText提供的很好的编辑器工具输入这些信息.

structs:
    TempStruct
        tempValue : double;
            unitOfMeasurement : String;

abilities :
    sensors:    
        TemperatureSensor
            generate tempMeasurement : TempStruct;
            attribute responseFormat : String;  
Run Code Online (Sandbox Code Playgroud)

上述DSL规范的语法如下:

       VocSpec:

          'structs' ':'
          (structs += Struct)+

          'abilities' ':'
           ('sensors' ':' (sensors += Sensor)+ )+ 
         ;

      Sensor:
          name = ID
          ((attributes += Attributes ) |
          (sources += Sources))* 
          ;

     Sources:
          'generate' name=ID ':' type = Type ';' 
           ;

     Attributes:
         'attribute' name=ID ':' type = Type ';' 
           ; 

    Struct:
          name = ID
          (fields += Field)+ 
         ;

    Field:
         name=ID ':' …
Run Code Online (Sandbox Code Playgroud)

java stringtemplate xtext

4
推荐指数
1
解决办法
2667
查看次数

标签 统计

java ×1

stringtemplate ×1

xtext ×1