嘿,作为一个提高我的编程技能的项目,我已经开始用 python 编写一个很好的代码编辑器来自学项目管理、版本控制和 GUI 编程。我想利用为其他程序制作的语法文件,这样我就可以拥有一个大的集合。我想知道是否存在与 .odt 文件大致相同的通用语法文件格式。我曾经在论坛上听说过一个,它有一个网站,但我现在不记得了。如果没有,我可能会尝试使用 gedit 语法文件或 geany。
谢谢
Hey as a project to improve my programing skills I've begun programing a nice code editor in python to teach myself project management, version control, and gui programming. I was wanting to utilize syntax files made for other programs so I could have a large collection already. I was wondering if there was any kind of universal syntax file format much in the same sense as .odt files. I heard of one once in a forum, it had a website, but I can't remember it now. If not I may just try to use gedit syntax files or geany.
thanks
发布评论
评论(2)
如果您打算进行语法突出显示,请查看 Pygments,尤其是关于 词法分析器。
既然您提到了 Geany,您可能需要查看 Scintilla 文档。 (Geany 是建立在 Scintilla 之上的)。
您可能会发现这篇文章很有趣。
另外,请务必熟悉古老的 lex 和 yacc。
If you're planning to do syntax highlighting, check out Pygments, especially the bit about lexers.
Since you mentioned Geany, you might want to look at the Scintilla docs. (Geany is built upon Scintilla).
You might find this post interesting.
Also, be sure to get familiar with the venerable lex and yacc.
不确定 .odt 与此有什么关系。
我可以看到某种 BNF 能够描述(几乎)任何语法:只需通过解析器运行文本和 BNF,并将配色方案应用于终端。你甚至可以变得更奇特,因为你有语法树。
实际上,我认为大多数语法文件都采用更简单的方法,例如正则表达式。这将置于正则表达式之上,但在功能方面并不是真正与上下文无关。
至于文件格式,如果您重复使用现有的东西,那么您就可以掠夺和掠夺(根据许可协议)它们的语法文件数据。
Not sure what .odt has to do with any of this.
I could see some sort of BNF being able to describe (almost) any syntax: Just run the text and the BNF through a parser, and apply a color scheme to the terminals. You could even get a bit more fancy, since you'd have the syntax tree.
In reality, I think most syntax files take an easier approach, such as regular expressions. This would put then somewhere above regular expressions but not really quite context-free in terms of power.
As for file formats, if you re-use something that exists, then you can just loot and pillage (subject to license agreements) their syntax file data.