Convert simple Antlr grammar to Xtext

后端 未结 1 1944
深忆病人
深忆病人 2021-02-20 13:40

I want to convert a very simple Antlr grammar to Xtext, so no syntactic predicates, no fancy features of Antlr not provided by Xtext. Consider this grammar

gram         


        
1条回答
  •  忘掉有多难
    2021-02-20 14:09

    It's basically not possible to do this conversion automatically since the Antlr grammar lacks information that is required in the Xtext grammar. The rule names in Xtext will be used to create classes from them. There are assignments in Xtext that will become getters and setters in those classes. However, these assignments should not be used for every rule call since there are special patterns in Xtext that allow to reduce the noise in the resulting AST. Stuff like that makes it hardly possible to do this transformation automatically. However, it's usually straight forward to copy the Antlr grammar into the Xtext editor and fix the issues manually.

    0 讨论(0)
提交回复
热议问题