Emacs 有 BNF 模式吗?
我必须编辑大量 .bnf 格式的语法文件。 Emacs 中有这样的模式吗?
我查看了 CEDET 的语义包,它似乎曾经有 bnf 模式,但现在不再有。这段代码可以在谷歌上搜索,但语义 bnf-mode 似乎不存在:
(autoload 'semantic-bnf-mode "semantic-bnf" "Mode for Bovine Normal Form." t)
(add-to-list 'auto-mode-alist '("\\.bnf$" . semantic-bnf-mode))
I have to edit lots of grammar files in .bnf format. Is there a mode for this in Emacs?
I've looked at CEDET's semantic package, and it seems that it USED to have a bnf-mode, but not any more. This snippet is googlable, but semantic-bnf-mode doesn't seem to exist:
(autoload 'semantic-bnf-mode "semantic-bnf" "Mode for Bovine Normal Form." t)
(add-to-list 'auto-mode-alist '("\\.bnf$" . semantic-bnf-mode))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
谢谢唐。我稍微改进了代码,这是一个新版本。
Thanks Don. I improved the code very slightly, here's a new version.
语义 bnf 模式适用于其自己的内部解析器格式。最初的“bnf”这个名字是一个双关语,最终让人们感到困惑。
现有的语义模式如wiset-grammar-mode和bovine-grammar-mode是针对CEDET使用的语法的,原始的bnf-mode类似,并不代表真正的BNF风格语法。
您可能对 ebnf2ps 更感兴趣,它将 ebnf 语法(yacc 等)翻译成语法图表,尽管我自己没有使用过它。
The Semantic bnf mode was for its own internal parser format. The original 'bnf' name was a pun that ended up confusing people.
The existing Semantic modes such as wisent-grammar-mode and bovine-grammar-mode are for the grammars used by CEDET, and the original bnf-mode was similar, and did not represent a real BNF style grammar.
You are probably more interested in ebnf2ps, which translates ebnf grammars (yacc, etc) into syntax charts, though I haven't used it myself.
为了使答案更具可读性和可查找性,jmmcd 用以下内容回答了他自己的问题。您可以在 emacs 帮助 > 中找到更多信息省略号> 23.2.6 通用模式。
“我把它放在我的 .emacs 中,它似乎可以工作。”
To be more readable and findable as an answer, jmmcd answered his own question with the following. You can find more in the emacs Help > elisp > 23.2.6 Generic Modes.
"I put this in my .emacs and it seems to work."
我刚刚创建了一个 用于编辑 BNF 语法的 GNU Emacs 主要模式。
目前为 BNF 文件提供基本语法和字体锁定。 EBNF 和 ABNF 都在我近期的计划中。
I just created a GNU Emacs major mode for editing BNF grammars.
Currently provides basic syntax and font-locking for BNF files. EBNF and ABNF are in my plans for the near future.