简体   繁体   English

如何为xtext创建自定义终端语法?

[英]How to create custom terminal grammar for xtext?

My grammar file is already too large and is causing the error: The code for the static initializer is exceeding the 65535 bytes limit. 我的语法文件已经太大,并导致错误:静态初始化程序的代码超过了65535个字节的限制。

So, I want to split my grammar into 2 xtext files, and create a separate custom terminal.xtext to lower down the size of my grammar file. 因此,我想将语法分为2个xtext文件,并创建一个单独的自定义terminal.xtext来减小语法文件的大小。

I have an xtext project in org.xtext.rpcIDL, where my RpcIDL.xtext is in its src directory. 我在org.xtext.rpcIDL中有一个xtext项目,我的RpcIDL.xtext在其src目录中。 I have read here that its possible to have 2 grammar files in one project. 我在这里读到,在一个项目中可能有2个语法文件。 But I cannot add another grammar file in my current project. 但是我不能在当前项目中添加另一个语法文件。 When I right-click, then go to New, there is no option there to add a new xtext file. 当我右键单击然后转到“新建”时,那里没有添加新的xtext文件的选项。

How can I add a custom xtext file in my project? 如何在项目中添加自定义xtext文件?

I don't know if you already found out the solution by yourself but in case you didn't: 我不知道您是否已经自己找到解决方案,但万一您没有找到:
To create a new Xtext-File in your project right click in your org.xtext.rpcIDL which should be in your text-project under src (The one with the package symbol in front of it), then go to New->File and then you just have to give it a name and add the extension .xtext . 要在您的项目中创建一个新的Xtext-File,请右键单击org.xtext.rpcIDL ,该文件应该在src下的文本项目中(前面带有包符号的那个),然后转到New-> File,然后那么您只需给它起一个名字并添加扩展名.xtext That will add the xtext-nature to your project. 这会将xtext-nature添加到您的项目中。 After that you have to add the line grammar ... (just copy this line of your other file and change the last element to the name of your new File). 之后,您必须添加行grammar ... (只需复制其他文件的这一行并将最后一个元素更改为新文件的名称)。 Then add with and enter the name of your other xtext-file (this is the one which stands after the generate in your other file. Then you should be able to use the elements of all the features which you have declared in your original File. 再加入with ,并输入您的其他XTEXT文件的名称(这是它代表了一前一后generate您的其他文件。然后,你应该能够使用的所有您在原始文件中有声明的特征元素。
I hope I could help you. 希望能对您有所帮助。
Greets Krzmbrzl 问候克尔兹姆布尔兹尔

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM