简体   繁体   English

Atom文本编辑器如何解析/标记代码? (语法突出显示)

[英]How does atom text editor parse / tokenise code? (syntax-highlighting)

So CodeMirror uses modes to tokenise its code . 因此CodeMirror使用modes来标记其代码
It breaks up the document into lines and makes each line a stream, which is then put through into the pre-defined mode . 它将文档分成几行,使每一行成为一个流,然后将其置于预定义mode It can span multiple lines by using its state parameter. 通过使用其state参数,它可以跨越多行。
It seems ACE has a similar method . 看来ACE也有类似的方法

Neither of these methods use RegExp inherently (but obviously whomever creates the mode can code in RegExp into their mode). 这些方法都不是固有地使用RegExp的(但是显然创建模式的任何人都可以将RegExp编码为它们的模式)。

From what I've read of Atom's code and style, is that it calls different syntax highlighters grammars and they resemble closely the grammars from TextMate. 从我对Atom的代码和样式的了解中可以看出,它调用了不同的语法突出显示grammars并且它们与TextMate的grammars非常相似。 These grammars resemble JSON objects which contain classnames and RegExps ( see how to write a TextMate grammar ). 这些grammars类似于JSON对象,其中包含类名和RegExps( 请参阅如何编写TextMate语法 )。

I can't figure out for the life of me how exactly Atom Text Editor actually performs the parsing of code, keeping its state and also extending through various scopes. 我一辈子都无法弄清楚Atom Text Editor究竟是如何准确地执行代码解析,保持其状态以及扩展各种作用域的。

If someone could point me in the right direction that would be great. 如果有人可以指出正确的方向,那将是很好的。

您最好在Atom论坛中提出问题,因为Atom开发人员经常访问它们。

The question was answered here . 这里回答这个问题。

Atom uses its first-mate module, which relies on oniguruma for parsing Regular Expressions. Atom使用其first-mate模块,该模块依靠oniguruma解析正则表达式。

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

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