生成将解析具有给定 BNF 格式的文件的 Delphi 代码

发布于 2025-01-07 20:43:32 字数 677 浏览 4 评论 0原文

是否有用于 Delphi 的解析器代码或解析器组件或接受 BNF(巴科斯范式)表示法作为输入并生成 Delphi(或 pascal)代码来进行解析的程序?

这样做的原因是我将尝试完美解析以下各种版本的数据集 GEDCOM 标准(用于谱系),并且需要在达到令牌时处理不同状态的文件。我更喜欢一个自动化程序来完成设置基本 pascal 代码的繁重工作,为我进行状态到状态处理。

否则,我将不得不自己手动构建状态结构。

我确实看到了以下问题(以及 TinyPG 看起来不错,但我需要 Delphi 代码): 在给定 BNF 语法的情况下输出 C# 的解析器生成器?< /a>

如果没有这样的野兽,是否有其他可用的工具可以使这项任务变得更容易?

Is there parser code or a parser component for Delphi or a program that will accept BNF (Backus-Naur Form) notation as input and produce Delphi (or pascal) code to do the parsing?

The reason for this is that I am going to be attempting to perfectly parse data sets following various versions of the GEDCOM standard (used for genealogy), and will need to process the file from state to state as tokens are reached. I would prefer an automated program to do the grunt work of setting up the basic pascal code to do the state to state processing for me.

Otherwise, I'll have to manually build the state structures myself.

I did see the following question (and TinyPG looks good, but I need Delphi code):
Parser-generator that outputs C# given a BNF grammar?

If there isn't such a beast, are there any other tools available that will make this task easier?

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

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

发布评论

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

评论(1

轻拂→两袖风尘 2025-01-14 20:43:32

我向您推荐 GOLD 解析系统。 GOLD 语法基于 Backus-Naur 形式和正则表达式。

资源

引擎

特别列出了 Delphi 引擎此处

这是 Rob van 为 Object Pascal 设计的 den Brink 可能会感兴趣。

引用:

Rob van den Brink 更新了他的 Object Pascal 编程引擎
语言。他的实现使用程序模板来创建
全功能程序。这种方法嵌入了解析表
直接在源代码中。因此,您不需要加载
编译的语法表文件。下载包含程序模板
以及几个示例。

使用GOLD的示例项目

GOLD功能强大,它用作dcu2pas的解析引擎,一个 Delphi 编译单元(dcu 文件)反编译器,托管于 此处 (bitbucket.org)。请注意,它是用 编写的。

I recommend you the GOLD parsing system. GOLD grammars are based on Backus-Naur form and regular expressions.

Resources

Engines

Engines for Delphi are particularly listed here.

This one for Object Pascal by Rob van den Brink might be of interest.

Quote:

Rob van den Brink updated his engine for the Object Pascal Programming
Language. His implementation uses a program template to create a
full-functioning program. This approach embeds the parse tables
directly in the source code. As a result, you do not need to load a
Compiled Grammar Table file. The download contains a program template
as well as several examples.

Sample project using GOLD

GOLD is powerfull, it is used as the parsing engine of dcu2pas, a Delphi Compiled Unit (dcu files) decompiler which is hosted here (bitbucket.org). Notice instead that it's written in .

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