语法高亮是如何构建的?

发布于 2024-08-17 15:00:14 字数 236 浏览 2 评论 0原文

我现在正在使用 Lazarus 构建一个开发人员编辑器,并且作为每个优秀的开发人员编辑器,它需要有语法突出显示,因此我想知道一些事情:

  • 语法突出显示通常是如何构建的(使用许多 if< /code>s 更改 TextField 上的字体
  • 非常好?
  • 如何使用 TSynEdit(链接和资源) ?

I'm now building a developers editor using Lazarus and as every good developers editor, it needs to have a syntax highlighting, because of this that I want to know some things:

  • How is syntax highlight normally built(using many ifs to change the font on a TextField?
  • TSynEdit is very nice to do this?
  • How to use TSynEdit(links and resources)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

傲娇萝莉攻 2024-08-24 15:00:14

如果您查看 SharpDevelop 编辑器。它是用 C# 实现的,但使用了出色的 OOP,可以轻松移植到其他平台或语言。

大多数自制的语法荧光笔倾向于使用 MS Windows RichText 控件,但它们通常缓慢且笨重,并且在添加大量代码时速度确实会变慢。

You can actually see an excellent example for yourself if you look at the editor for SharpDevelop. It's implemented in C# but uses great OOP that should be readily portable to other platforms or languages.

Most home-brewed syntax highlighters tend to use the MS Windows RichText control but they're usually slow and clunky and really slow down when a lot of code is added.

澉约 2024-08-24 15:00:14

你可以阅读Eclipse或VIM的源代码。在 Eclipse 中,您将找到一个抽象语法树库。最重要的是精心编写的解析器可以容忍错误,因为正在进行的代码通常不满足该语言的完整语法。突出显示使用语法树中的信息。

You could read the source code of Eclipse or VIM. In Eclipse you will find an Abstract Syntax Tree base. On top of it are parsers that are carefully written to be tolerant of errors, since code in progress often does not satisfy the full grammar of the language. The highlighting uses the information in the syntax tree.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文