使用“ ace”添加新语言。图书馆 [英] Adding a new language with "ace" library

查看:103
本文介绍了使用“ 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.

由于两种表示法都是形式化的,并且涵盖了基本上相同的基础(词法层面的规范),因此您可以考虑 build 为您进行映射。这可能比单纯手工翻译要付出更多的努力。 (是的,我非常喜欢自动化工具。知道它们何时有用非常重要)。

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天全站免登陆