Adding a new language with “ace” library

房东的猫 提交于 2019-12-23 22:52:47

问题


I'm new to Ace, and I want to add a new language.

I created the file named new_highlight_rules , the problem is I have to add tokens and corresponding regex in this file, and my new language is very complicated, so I have a lot of regex and rules to add.

My question is: if I have the grammar of my language written for ANTLR, is there a practical way to add regexes and tokens? and is there any other way without using ANTLR?

Please I'm new and any guidance, even very basic, can help me.


回答1:


If Ace has one way of writing regexes that doesn't match those of ANTLR lexers, then you will likely have to translate your ANTLR regexes manually.

As a general rule, I've never seen two language definition systems that used exactly the same syntax for specifying the details, so I'm pretty sure you are stuck.

As both notations are formal, and cover essentially the same ground (lexical-level specifications), you could contemplate building a translator to do the mapping for you. That's likely way more effort than simply doing the translation by hand. (And yes, I'm a big fan of automated tools. Its important to know when they are useful).



来源:https://stackoverflow.com/questions/35362404/adding-a-new-language-with-ace-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!