添加带有“ace"的新语言图书馆 [英] Adding a new language with "ace" library

查看:16
本文介绍了添加带有“ace"的新语言图书馆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Ace 的新手,我想添加一种新语言.

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

我创建了名为 new_highlight_rules 的文件,问题是我必须在这个文件中添加标记和相应的正则表达式,而我的新语言非常复杂,所以我有很多正则表达式和规则添加.

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.

我的问题是:如果我为 ANTLR 编写了我的语言的语法,是否有添加正则表达式和标记的实用方法?有没有不使用ANTLR的其他方法?

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.

推荐答案

如果 Ace 有一种与 ANTLR 词法分析器不匹配的正则表达式编写方式,那么您可能需要手动翻译您的 ANTLR 正则表达式.

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).

这篇关于添加带有“ace"的新语言图书馆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆