如何通过解析 C 程序并将其转换为要显示的电路图来进行反向建模

发布于 2024-09-15 12:46:36 字数 200 浏览 1 评论 0原文

如何通过解析 C 程序并将其转换为要显示的电路图来进行反向建模。

示例

alt 文本

alt text

除了这是伪代码。

How can I do modeling in reverse by parsing a C program and turning it in to a circuit diagram to be displayed.

Example

alt text

alt text

Except this is psedocode.

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

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

发布评论

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

评论(1

篱下浅笙歌 2024-09-22 12:46:36

乍一看,我会说你需要从头开始构建一个 C 编译器(或选择一个),并检查解析树,寻找可以用简单符号列表表示的结构。完成此操作后,您需要一个渲染引擎来获取检测到的构造列表并将它们排列在漂亮的图片中。

一些随机观察:

  1. 有很多 C 概念无法以简单化的方式呈现(即指针)

  2. < p>让你的照片看起来漂亮会是个婊子

  3. Doxygen 将是寻找想法的好地方(做一个漂亮的函数调用结构图)

  4. 偏离正题,您可能想看看IEC 61131-3 PLC 编程语言。这些是图形化的语言,提供了 5 种不同的方式来描述程序控制,并重点关注逻辑的表示

At a first guess I would say you need to construct a C compiler from scratch (or co-opt one) and inspect the parse tree looking for constructs that you can represent with your list of simple symbols. Once you have done that you need a rendering engine to take the list of detected constructs and lay them out in a pretty picture.

Some random observations:

  1. There are many C concepts that can't be rendered in a simplistic manner (ie pointers)

  2. Making your pic look pretty will be a bitch

  3. Doxygen would be a good place to look for ideas (the do a nice function call structure graph)

  4. Going off on a tangent you might like to look at IEC 61131-3 programming languages for PLCs. These are graphically laid out languages that provide 5 different ways of describing program control and focus heavily on representations of logic

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